name: DataGrid attributes: editable: type: boolean behavior: Enable row, field, cell, and save controls. state: fields: Array of column definitions; assign before list. list: Array of row objects; each key matches a field id. _originalList: Internal unfiltered row snapshot. sortConfig: "{ fieldId, direction }" filterConfig: Per-field filter configuration. selectedRowCount: Selected row count. isDirty: Whether edits are pending save. editing: formTypes: [text, number, select, checkbox, radio, switch, textarea, date, datetime, TagsInput, DatePicker, ColorPicker, IconPicker] rule: Double-click an editable cell, then click outside the editor or press Enter to save its bound value. filtering: rule: Click a column header, enter a value in its menu, and the grid filters immediately. Use the menu controls for sort and reset. field: required: [id, name] fields: id: Unique column id and row value key. name: Header label. type: Source value type. memo: Field description. settings: "{ width, pinned, formType, options, decimals, prefix, suffix, thousandSep, labelOn, labelOff }" formatter: Function receiving value and field. methods: addRow: Add an empty row. deleteSelectedRow: Delete selected rows. saveChanges: Dispatch save. addField: Add a field. editField: Edit the active field. deleteField: Delete the active field. editCell: Open a cell editor. applySortFilter: Apply current or supplied sorting and filters. onScroll: Refresh the virtual row window after scrolling. events: save: detail: "{ list, fields }" savefields: detail: fields remove: detail: "{ items }" global: DataGrid: methods: registerFieldType: Register a field type configuration. getFieldTypes: Return registered field types. related: - ../base/AutoForm.yaml - ../base/Modal.yaml - ../base/Dialog.yaml - ../../utilities/VirtualScroll.yaml - ../base/Resizer.yaml - ../form/DatePicker.yaml - ../form/ColorPicker.yaml - ../form/IconPicker.yaml - ../form/TagsInput.yaml rules: - Bind fields and list with $.state.fields and $.state.list. - Give the DataGrid or its parent an explicit height so virtual scrolling has a viewport. - Treat underscore-prefixed state fields as internal read-only diagnostics. - Custom field editors must be registered in AutoForm before use. example: |
tests: - DataGrid.test.html