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=1211)



RecordGrid のセル単位のフォーカス制御方法 - kay - 03-06-2015

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

RecordGrid で、特定のカラムののフォーカス可否を行単位に制御する場合、
どのようにしたらよいでしょうか?

例えば、下図のようなグリッドで、各行が非表示で持っている eol の値によって
各行の amount 列のフォーカス可否を制御したい、といった内容です。
  product  amount
1    A
2    B
3    C

ものすごく基本的なことかとは思うのですが、中々答えにたどりつけておりません…。
ご教示いただけると幸いです。



RE: RecordGrid のセル単位のフォーカス制御方法 - dankom - 03-06-2015

こんな感じでしょうか…

Code:
{define-class public MyEnterKeyCell {inherits StandardStringCell}
  
  {constructor public {default}
    {construct-super}
  }
  
  {method public {refresh-data}:void
    {super.refresh-data}
    
    {dump self.record["edit"]}
    {if self.record["edit"] == 0 then
        set self.cells-take-focus? = false
    else
        set self.cells-take-focus? = true
    }
  }
  
}


{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 = 28, 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 = 28, 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", cell-spec = MyEnterKeyCell}
    }
}

{value
    {VBox
        rg,
        {CommandButton
            label = "append record",
            {on Action do
                {people.append {RecordData}}
            }
        }
    }
}



RE: RecordGrid のセル単位のフォーカス制御方法 - kay - 03-06-2015

Cell のクラスを自前で作成するんですね…。
おかげ様で期待通りの動きになりそうです。
ありがとうございました!