セルの最大入力桁数を可変にするには

【ご質問】
Recordのあるフィールドの値をもとに、別フィールドの最大入力桁数を制御したいのですが可能でしょうか。

【回答】
カスタムセルを使用し、「refresh-data (メソッド)」内で制御処理を行うことで実現可能です。

詳細は以下のサンプルをご参照ください。

{curl 6.0,7.0,8.0 applet}
{curl-file-attributes character-encoding = “shif-jis”}

{def grid =
    {RecordGrid
        record-source = {RecordSet
                                   {RecordFields
                                       {RecordField “id”},
                                       {RecordField “halign”},
                                       {RecordField “length”},
                                       {RecordField “value”, domain = String, nullable? = true}
                                   },
                                   {RecordData id = “A001”, halign = 0.0, length = 4},
                                   {RecordData id = “A002”, halign = 1.0, length = 7},
                                   {RecordData id = “A003”, halign = 0.3, length = 3},
                                   {RecordData id = “A004”, halign = 0.7, length = 1},
                                   {RecordData id = “A005”, halign = 0.5, length = 5}
                               },
        automatic-columns? = false,
        editable? = true,
        {RecordGridColumn “id”, editable? = false},
        {RecordGridColumn “length”, editable? = false},
        {RecordGridColumn “value”, cell-spec = MaxCharChangeableCell}
    }
}

{define-class public MaxCharChangeableCell {inherits StandardStringCell}

  {method public {refresh-data}:void
    {if-non-null editor = self.current-editor, rec = self.record then
        {try
            set editor.halign = rec[“halign”] asa double
            set editor.max-chars = rec[“length”] asa int
         catch e:Exception do
            {dump e}
        }
    }
    {super.refresh-data}

  }
}

{View
    grid,
    visibility = “normal”,
    {on WindowClose do
        {exit}
    }
}