DataGrid
Feature-rich data table with sorting, pagination, column resize/reorder, grouping, filtering, row selection, toolbar, and remote data support.
Local Data (Client-side)
Remote Data (Server-side Pagination)
With Grouping
Interact with a grid to see output...
PHP PHP Methods (Fluent)
| Method / Property | Parameters | Description |
|---|---|---|
$m->dataGrid($id) | string | Create a DataGrid component. |
->columns($cols) | array | Define columns. Each column: field, title, width, sortable, format, template, component, align, frozen, hidden, wrap. |
->dataSource($data) | array | Provide local data (array of assoc arrays). |
->remoteUrl($url, $method) | string, string | Fetch data from a remote URL. Expected response: {data: [], total: N}. |
->remoteHeaders($headers) | array | Extra HTTP headers for remote requests. |
->pageable($pageSize, $mode) | int, string | Enable pagination. Mode: local or remote. |
->sortable() | | Enable column sorting. |
->resizable() | | Enable column resize. |
->reorderable() | | Enable column drag-reorder. |
->groupable() | | Enable row grouping by column. |
->selectable() | | Enable single-row selection. |
->filterable() | | Add column filter inputs. |
->extraParams($params) | array | Extra params sent with every remote request. |
->height($height) | string | Set fixed height with scrollable body (e.g. 400px). |
->striped() | | Enable striped rows. |
->borderless() | | Remove outer border. |
->toolbar($buttons) | array | Add toolbar buttons: [text, icon, click, class]. |
->emptyState($title, $msg) | string, string | Empty-data message. |
->onDataBound($callback) | string | JS callback after data renders. |
->onRowClick($callback) | string | JS callback on row click. |
->onRowSelect($callback) | string | JS callback on row selection. |
->onRowExpand($callback) | string | JS callback on group expand/collapse. |
JS JS Methods
| Method / Property | Parameters | Description |
|---|---|---|
m.dataGrid(id, opts) | string, ?object | Get or create DataGrid instance. |
refresh() | | Re-fetch remote data (returns Promise for remote grids). |
setData(array) | array | Replace the local dataset. |
goToPage(num) | int | Navigate to a specific page. |
sort(field, dir) | string, string | Sort by field. Dir: asc or desc. |
clearSort() | | Clear current sort. |
clearFilters() | | Clear all column filters. |
groupBy(field) | string | Group rows by the given field. |
clearGroup() | | Remove grouping. |
setExtraParams(obj, merge) | object, ?bool | Set extra remote request params. Pass true to merge. |
getExtraParams() | | Get current extra params object. |
getData() | | Get the data array for the current page. |
getTotal() | | Get total record count. |
getSelectedData() | | Get the selected row data. |
destroy() | | Clean up event listeners and DOM. |
JS Column Component Types
| Method / Property | Parameters | Description |
|---|---|---|
badge | textBind, text, variant, variantBind, icon, iconBind | Render a badge in the cell. |
label | textBind, text, variant, variantBind, icon, iconBind | Render a styled label. |
icon | iconBind, icon | Render a Font Awesome icon. |
checkbox | valueBind, readonly | Render a checkbox (read-only by default). |
rating | valueBind, max, halfStars | Render a star rating. |
progressBar | valueBind, max, variant, showPercent, striped, animated | Render a progress bar. |