Grid with Row Editing
Grid supports arbitrary content inside its cells and this can be used to implement row editing.
| Name | Continent | Browser | OS | Visits | Actions |
|---|---|---|---|---|---|
Lucius Stark | Africa | Edge | Android | 37 | |
Leora Miller | Australia | Edge | Android | 99 | |
Wilburn Heller | South America | Internet Explorer | Mac OS | 83 | |
Fiona Wintheiser | South America | Safari | Ubuntu | 31 | |
Rosemary Yundt | Australia | Firefox | Ubuntu | 9 | |
Judge Blick | Africa | Firefox | Mac OS | 42 | |
Lucas Kassulke | Africa | Chrome | iOS | 95 | |
Marcellus Treutel | South America | Edge | Mac OS | 63 |
ControllerGrid
<Grid records-bind="$page.records" lockColumnWidths cached row={{ style: { background: {expr: "!!{$record.$editing} ? 'lightsteelblue' : null"} }, valid: { bind: '$record.valid' } }} columns={[ { header: "Name", field: "fullName", sortable: true, items: <cx> <TextField value-bind="$record.fullName" viewMode-expr="!{$record.$editing}" style="width: 100%" autoFocus required /> </cx> }, { header: "Continent", field: "continent", sortable: true, items: <cx> <TextField value-bind="$record.continent" viewMode-expr="!{$record.$editing}" style="width: 100%" required /> </cx> }, { header: "Browser", field: "browser", sortable: true, items: <cx> <TextField value-bind="$record.browser" viewMode-expr="!{$record.$editing}" style="width: 100%" required /> </cx> }, { header: "OS", field: "os", sortable: true, items: <cx> <TextField value-bind="$record.os" viewMode-expr="!{$record.$editing}" style="width: 100%" required /> </cx> }, { header: "Visits", field: "visits", sortable: true, align: "right", items: <cx> <NumberField value-bind="$record.visits" viewMode-expr="!{$record.$editing}" style="width: 100%" inputStyle="text-align: right" required /> </cx> }, { header: 'Actions', style: "width: 150px", align:"center", items: <cx> <Button mod="hollow" onClick="editRow" visible-expr="!{$record.$editing}">Edit</Button> <Button mod="hollow" onClick="deleteRow" visible-expr="!{$record.$editing}" confirm="Are you sure?">Delete</Button> <Button mod="primary" onClick="saveRow" disabled-expr="!{$record.valid}" visible-expr="!!{$record.$editing}">Save</Button> <Button mod="hollow" onClick="cancelRowEditing" visible-expr="!!{$record.$editing}">Cancel</Button> </cx> } ]} /> <p> <Button onClick="addRow">Add</Button> </p>