Thread Rating:
  • 307 Vote(s) - 2.72 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recordの選択状態の取得
04-23-2014, 11:38 AM,
#1
Recordの選択状態の取得
こんにちは!

今回はRecordGrid上で選択されているレコードのINDEXを
下記のコードを使って取得しているのですが、
INDEXの取得する順番?がバラバラで困っています。。。

0,1,2,3・・・のように昇順で取ってこれれば良いなと考えております!



ご教授お願いします。

Code:
{let index_box:VBox={VBox}}

{let test_set:RecordSet=
    {RecordSet
        {RecordFields
            {RecordField "A"}
            ,{RecordField "B"}
        }
        ,{RecordData A = "1" , B = "100"}
        ,{RecordData A = "2" , B = "200"}
        ,{RecordData A = "3" , B = "300"}
        ,{RecordData A = "4" , B = "400"}
        ,{RecordData A = "5" , B = "500"}
        ,{RecordData A = "6" , B = "600"}
        ,{RecordData A = "7" , B = "700"}
        ,{RecordData A = "8" , B = "800"}
        ,{RecordData A = "9" , B = "900"}
    }
}

{let test_grid:RecordGrid=
    {RecordGrid
        record-source = test_set
        ,width = {make-elastic minimum-size = 200 }
        ,height = {make-elastic minimum-size = 150 }
        ,{RecordGridColumn "A" ,width=80}
        ,{RecordGridColumn "B" ,width=80}
    }
}

{let btn:CommandButton=
    {CommandButton
        label="ボタン"
        ,{on Action do
             {if test_grid.selection.record-count == 0
              then
                 {popup-message "レコードを選択してください"}
              else
                 ||選択しているレコードのINDEXを取得する
                 {for i:int in test_grid.selection.records do
                     {index_box.add i}
                 }
                 ||INDEXを表示
                 {popup-message index_box}
                 {index_box.clear}
             }
         }
    }
}

{value
    {VBox
        test_grid
        ,btn
    }
}
04-23-2014, 03:07 PM,
#2
RE: Recordの選択状態の取得
「選択された順番」が関係しているようなので、
独自のルールでソートしたければ、いったん別の配列に入れてsort で並び替えてやるのがよさそうです。

Code:
def ary = {{Array-of int}}
def recs = test_grid.selection.records
{for i:int in test_grid.selection.records do
{ary.append i}
}
{ary.sort}
{for i:int in ary do
{index_box.add i}
}
||INDEXを表示
{popup-message index_box}
04-23-2014, 03:56 PM,
#3
RE: Recordの選択状態の取得
>umemuraさん

ありがとうございます!
一度配列に入れてからソートで並び替えたら簡単にできました!

勉強になりました!
ありがとうございます!

Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('1075')