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 PHP Methods (Fluent)

Method / PropertyParametersDescription
$m->dataGrid($id)stringCreate a DataGrid component.
->columns($cols)arrayDefine columns. Each column: field, title, width, sortable, format, template, component, align, frozen, hidden, wrap.
->dataSource($data)arrayProvide local data (array of assoc arrays).
->remoteUrl($url, $method)string, stringFetch data from a remote URL. Expected response: {data: [], total: N}.
->remoteHeaders($headers)arrayExtra HTTP headers for remote requests.
->pageable($pageSize, $mode)int, stringEnable 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)arrayExtra params sent with every remote request.
->height($height)stringSet fixed height with scrollable body (e.g. 400px).
->striped()Enable striped rows.
->borderless()Remove outer border.
->toolbar($buttons)arrayAdd toolbar buttons: [text, icon, click, class].
->emptyState($title, $msg)string, stringEmpty-data message.
->onDataBound($callback)stringJS callback after data renders.
->onRowClick($callback)stringJS callback on row click.
->onRowSelect($callback)stringJS callback on row selection.
->onRowExpand($callback)stringJS callback on group expand/collapse.

JS JS Methods

Method / PropertyParametersDescription
m.dataGrid(id, opts)string, ?objectGet or create DataGrid instance.
refresh()Re-fetch remote data (returns Promise for remote grids).
setData(array)arrayReplace the local dataset.
goToPage(num)intNavigate to a specific page.
sort(field, dir)string, stringSort by field. Dir: asc or desc.
clearSort()Clear current sort.
clearFilters()Clear all column filters.
groupBy(field)stringGroup rows by the given field.
clearGroup()Remove grouping.
setExtraParams(obj, merge)object, ?boolSet 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 / PropertyParametersDescription
badgetextBind, text, variant, variantBind, icon, iconBindRender a badge in the cell.
labeltextBind, text, variant, variantBind, icon, iconBindRender a styled label.
iconiconBind, iconRender a Font Awesome icon.
checkboxvalueBind, readonlyRender a checkbox (read-only by default).
ratingvalueBind, max, halfStarsRender a star rating.
progressBarvalueBind, max, variant, showPercent, striped, animatedRender a progress bar.