Thread Rating:
  • 212 Vote(s) - 2.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RecordGridの特定のセルにフォーカスを設定したい
03-09-2015, 09:55 PM,
#1
RecordGridの特定のセルにフォーカスを設定したい
お世話になっております。

RecordGrid内の特定のセルにフォーカスを設定する方法はあるのでしょうか?
※RecordGrid内の特定セルのチェックでエラーが発生し、該当のセルにフォーカスを設定する場合等

Reply
03-10-2015, 10:00 AM,
#2
RE: RecordGridの特定のセルにフォーカスを設定したい
RecordGridUI.set-grid-focusメソッドでフォーカスの設定ができます。
チェックを行ったタイミングでどのセルかを取得し、
そのセルを引数にset-grid-focusを呼べばフォーカスが当たります。

(セルの取得の仕方は、RecordGridUI.get-cell-at-index、
RecordGridUI.get-cell-atメソッドを使えばいいと思います。)


Code:
{curl 8.0 applet}
{curl-file-attributes character-encoding = "utf8"}

{let people:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField "First", domain = String},
            {RecordField "Last", domain = String},
            {RecordField "Age", domain = int},
            {RecordField "edit", domain = int}
        },
        {RecordData First = "John", Last = "Smith", Age = 25, edit = 0},
        {RecordData First = "Jane", Last = "Smith", Age = 29, edit = 1},
        {RecordData First = "Jane", Last = "Jones", Age = -1, edit = 0},
        {RecordData First = "Ben", Last = "Abrams", Age = 24, edit = 1},
        {RecordData First = "Sam", Last = "Jones", Age = 30, edit = 0},
        {RecordData First = "Nigel", Last = "Stevens", Age = 32, edit = 1},
        {RecordData First = "Bert", Last = "Stevens", Age = 26, edit = 0},
        {RecordData First = "John", Last = "Smith", Age = 25, edit = 0},
        {RecordData First = "Jane", Last = "Smith", Age = 29, edit = 1},
        {RecordData First = "Jane", Last = "Jones", Age = -1, edit = 0},
        {RecordData First = "Ben", Last = "Abrams", Age = 24, edit = 1},
        {RecordData First = "Sam", Last = "Jones", Age = 30, edit = 0},
        {RecordData First = "Nigel", Last = "Stevens", Age = 32, edit = 1},
        {RecordData First = "Bert", Last = "Stevens", Age = 26, edit = 0}
        
    }
}

{let rv:RecordView =
    {RecordView
        people
    }
}

{let rg:RecordGrid =
    {RecordGrid
        record-source = rv,
        automatic-columns? = false,
        {RecordGridColumn "First"},
        {RecordGridColumn "Last"},
        {RecordGridColumn "Age"}
    }
}

{value
    {VBox
        rg,
        {CommandButton
            label = "Check!!!",
            {on Action do
                let records:{Array-of Record} = {rv.select}
                {for r:Record in records do
                    {if r["Age"] < 0 then
                        let checked-index:int = {rv.get-index r}
                        
                        let rg-ui:RecordGridUI = rg.ui-object asa RecordGridUI
                        let target-cell:#RecordGridCell =
                            {rg-ui.get-cell-at-index
                                checked-index,
                                2
                            }
                        {if-non-null target-cell then
                            {rg.become-active}
                            {rg-ui.set-grid-focus target-cell}
                            {break}
                        }
                    }
                }
            }
        }
    }
}
Reply
03-11-2015, 08:53 PM,
#3
RE: RecordGridの特定のセルにフォーカスを設定したい
教えていただいたソースを参考に作成したところ、
セルにフォーカスを設定できることを確認いたしました。
ありがとうございます。
Reply

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('1215')