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