Curl Global Community
RecordGridの特定のセルにフォーカスを設定したい - Printable Version

+- Curl Global Community (https://communities.curl.com)
+-- Forum: Discussions (https://communities.curl.com/forumdisplay.php?fid=1)
+--- Forum: General Curl questions (https://communities.curl.com/forumdisplay.php?fid=2)
+--- Thread: RecordGridの特定のセルにフォーカスを設定したい (/showthread.php?tid=1215)



RecordGridの特定のセルにフォーカスを設定したい - Yudai-s - 03-09-2015

お世話になっております。

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




RE: RecordGridの特定のセルにフォーカスを設定したい - dankom - 03-10-2015

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}
                        }
                    }
                }
            }
        }
    }
}



RE: RecordGridの特定のセルにフォーカスを設定したい - Yudai-s - 03-11-2015

教えていただいたソースを参考に作成したところ、
セルにフォーカスを設定できることを確認いたしました。
ありがとうございます。