eiseGrid PHP class is the backend for eiseGrid library that displays data grid, handles client side operations (data input, calculation and validation) and data update on the server side. Grid is configured on PHP side and rendered as HTML+JavaScript. Data is submitted to server as form data POST and can be obtained via JSON or directly posted into database.
eiseGrid integrates tightly with eiseIntra framework, but can be used as standalone component as well.
Package: eiseIntra
Version: 2.5beta
Copyright: (c) 2006-2025 Ilya S. Eliseev
Author: Ilya Eliseev (ie@e-ise.com)
License: MIT License
Subpackage: eiseGrid
eiseGrid class
This class is responsible for managing the data grid, including rendering, data manipulation, and interaction with the backend.
This array defines default properties of each column.
public $col_default = array(
'field' => '', // field name, must be set
'fields' => null, // array of fields, if set, will be used for colspan purposes
'title' => '', // column title
'type' => 'text', // column type
'style' => '', // column style
'class' => '', // column class
'mandatory' => false, // is column mandatory
'sortable' => false, // is column sortable
'filterable' => false, // is column filterable
'headerClickable' => false, // is column header clickable
'readonly' => false, // is column read-only
'disabled' => false, // is column disabled
'static' => false, // is column static, i.e. not editable
'default' => null, // default value for the field
'flagDontUpdateRow' => false, // if true, the row will not be updated on change of this field
'totals' => null, // totals for the column, can be 'sum', 'count', 'avg', 'min', 'max'
'decimalPlaces' => null, // number of decimal places for the column, if applicable
'source' => null, // source for the column, can be array of options, SQL query or string with options
'source_prefix' => null, // prefix for the source, if applicable
'href' => null, // link for the column, if applicable
'target' => null, // target for the link, if applicable
'format' => null, // date-time format for the column, if applicable
);
Category: Grid Configuration
array of columns. can be associative or indexed.
Category: Grid Configuration
Configuration of eiseGrid instance (see eiseGrid::$defaultConf for possible settings)
Category: Grid Configuration
array of rows. each row is accociative array of fieldName=>fieldValue
Category: Grid Data
Default widths for column types
static $defaultWidthsByType = array(
'numeric' => '60px'
, 'number' => '60px'
, 'integer' => '60px'
, 'real' => '80px'
, 'money' => '80px'
, 'date' => '90px'
, 'datetime' => '120px'
, 'time' => '40px'
, 'boolean' => '30px'
, 'checkbox' => '30px'
, 'order' => '25px'
, 'text' => '100px'
, 'combobox' => '100px'
, 'select' => '100px'
);
Category: Grid Configuration
Default config of eiseGrid
static $defaultConf = Array(
'titleDel' => "Del" // column title for Del
, "titleAdd" => "Add >>" // column title for Add
, 'controlBarButtons' => ''
//, 'controlBarButtons' => 'add|insert|moveup|movedown|delete|excel|save'
, 'extraInputs' => Array("DataAction"=>"update")
, 'urlToSubmit' => ''
, 'dateFormat' => "d.m.Y"
, 'timeFormat' => "H:i"
, 'decimalPlaces' => "2"
, 'decimalSeparator' => "."
, 'thousandsSeparator' => ","
, 'totalsTitle' => 'Totals'
, 'noRowsTitle' => 'Nothing found'
, 'spinnerTitle' => 'Loading...'
, 'dropHereTitle' => 'Drop it here'
, 'arrPermissions' => Array("FlagWrite" => true)
, 'Tabs3DCookieName' => '%s_tabs3d'
, 'class' => ''
, 'eiseIntraRelativePath' => eiseIntraRelativePath
, 'excelSheetName' => 'Sheet 1'
, 'excelFileName' => 'table.xls'
, 'colors' => array('#d79695', '#bd5050', '#fdc138', '#feff48', '#94d05e', '#928958', '#26afec', '#588cd0', '#b2a1c5', '#95cddb')
, 'intra' => null // intra object, if not set, will be taken from GLOBALS
);
Category: Grid Configuration
Grid constructor.
Parameters:
Category: Grid Configuration
This method renames Grid: it sets $grid->name and other attributes.
Parameters:
Returns: string - old name
Category: Grid Configuration
This function adds columns to $Columns property.
Parameters:
Category: Grid Configuration
This function removes columns from $Columns list.
Parameters:
Category: Grid Configuration
This function changes column property to defined values and returns its previous value.
Parameters:
Returns: mixed - old property value
Category: Grid Configuration
This function does main job: it generates HTML for the whole eiseGrid.
Parameters:
Category: Grid Display
This function echoes eiseGrid HTML
Parameters:
Category: Grid Display Grid Backward Compatibility
This function updates data in the database basing on user eiseGrid input
Parameters:
Category: Grid Data Handling
This function returns JSON-encoded data from eiseGrid input
Parameters:
Returns: JSON-encoded string or array of data
Category: Grid Data Handling
Category: Grid Backward Compatibility
Deprecated: since version 3.7.0
Class easyGrid is kept for backward compatibility. Please use eiseGrid instead.
eiseGrid jQuery wrapper
requires jQuery UI 1.8: http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
Published under MIT license (c)2006-2025 Ilya S. Eliseev ie@e-ise.com, easyise@gmail.com
Contributors:
eiseGrid reference: http://russysdev.github.io/eiseIntra/gridlist
Category: Grid Display
eiseGrid class constructor. Object of this class encapsulates all grid functionality. jQuery plugins are just wrappers around this class methods. See jQuery plugins documentation for details.
Category: Grid Display
Color the selected rows in the grid basing on the predefined colors in the grid configuration chosen by the user from the color picker dialog
Plugin initialization method.
Parameters:
Category: Grid Display
This method adds a new row to the grid.
Parameters:
Category: Grid Manipulation
Method selectRow “selects” a row in the grid by adding it to the set of selected rows and coresponding CSS class to it.
Parameters:
Category: Grid Manipulation
This method copies the specified rows.
Parameters:
Category: Grid Manipulation
This method returns the jQuery object of the last selected row in the grid.
Category: Grid Manipulation
Returns: {*} jQuery object of the last selected row in the grid.
This method returns an array of jQuery objects of all selected rows in the grid.
Returns: {*} Array of jQuery objects of all selected rows in the grid.
Category: Grid Manipulation
This method returns the ID of the specified row. ID is the contents of field marked as row_id in the grid configuration on PHP side.
Parameters:
Returns: {*} ID of the row
Category: Grid Manipulation
This method returns the ID of the last selected row in the grid. ID is the contents of field marked as row_id in the grid configuration on PHP side.
Parameters:
Returns: {*} ID of the last selected row
This method returns an array of IDs of all selected rows in the grid. IDs are the contents of field marked as row_id in the grid configuration on PHP side.
Parameters:
Returns: {*} Array of IDs of all selected rows
Category: Grid Manipulation
This function deletes a row from the grid.
Parameters:
Category: Grid Manipulation
This function deletes selected rows from the grid.
You can add user confirmation before deletion by adding beforeDelete callback to the eiseGrid object.
Example:
$('#myGrid').eiseGrid('beforeDelete', function(selectedRowIDs, event){
return confirm('Are you sure you want to delete rows: '+selectedRowIDs.join(', ')+'?');
});
Parameters:
Category: Grid Manipulation
Function marks the specified row as updated. Can be called after changing values in the row programmatically.
Parameters:
<tbody> jQuery object of the row(s) to be marked as updated.Category: Grid Manipulation
Special function that recalculates order field (with type='order' in grid config) values for all rows in the grid.
Category: Grid Manipulation
Function moves the selected row up by 1 step, if possible.
Parameters:
true rows remain not marked as ‘updated’ during this move.Category: Grid Manipulation
Function moves the selected row down by 1 step, if possible.
Parameters:
true rows remain not marked as ‘updated’ during this move.Category: Grid Manipulation
Special function that brings data that correspond to tab ID to the front.
Parameters:
Category: Grid Tabs
recalcTotals method recalculates totals for the specified field in all grids matching the selector.
Parameters:
Returns:
Function returns current totals for the specified field in all grids matching the selector. Toltals formula is defined in grid configuration on PHP side.
Parameters:
Category: Grid Data
Returns: {*} totals value
change method assigns “change” event callback for fields enlisted in strFields parameter.
Parameters:
Returns:
This method sets or retrieves value for field strField in specified row $tr.
Parameters:
<tbody> which encloses one or more rows.Category: Grid Data
Returns: the value of the field if only $tr and strField parameters are set; otherwise, returns undefined.
This method sets and/or returns text representation of data for field strField in specified row $tr.
Parameters:
<tbody> which encloses one or more rows.Category: Grid Data
Returns: {string} - text representation of the value
This method sets focus to field strField in specified data row $tr.
Parameters:
<tbody> which encloses one or more rows.Category: Grid Manipulation
Validates data for field strField in row tr. Returns true if valid.
Parameters:
<tbody> which encloses one or more rows.Category: Grid Data
Returns: {boolean} - true if valid
Validates entire contents of eiseGrids matching selectors. Returns true if all data in all grids is valid.
Parameters:
Category: Grid Data
Returns: {boolean} - true if all data in all grids is valid
This method wraps whole grid with FORM tag and submits it to script specified in settings. Then this data is sent to the server for processing.
Parameters:
Category: Grid Data Handling
This method sets the height of the grid. Parameter nHeight specifies the new height in pixels and includes header and footer if any.
Parameters:
Category: Grid Display
dblclick method assigns double-click event callback for all data rows in the grid.
Parameters:
Category: Grid Events
This method assigns a callback function to be executed before a row is deleted. If this function returns false, the deletion is cancelled.
grid.beforeDeleteCallback fires only with eiseGrid('deleteSelectedRows') method.
Parameters:
Category: Grid Events
Returns:
This method assigns a callback function to be executed after deletion of a row. This function can be used to perform some actions in the UI or send AJAX request to the server to delete the row from the database.
grid.afterDeleteCallback fires only with eiseGrid('deleteSelectedRows') method.
Parameters:
Category: Grid Events
Returns:
onDelete method assigns onDeleteCallback callback function that fires on any row deletion - doesnt matter if by eiseGrid('deleteSelectedRows') (from UI) or eiseGrid('deleteRow') method (both UI and programmatically). Doesnt matter what this function returns - row is always deleted.
Parameters:
Category: Grid Events
Returns:
This method assigns a callback function to be executed before saving data from the grid. If this function returns false, the save operation is cancelled. Can be used for data validation before save.
Parameters:
Category: Grid Events
Grid Data Handling
Returns:
This method returns the eiseGrid object associated with the current jQuery element. This can be useful for accessing grid methods and properties via eiseGrid object.
Returns: {Object} The eiseGrid object.
This method resets the grid: it clears all data and restores default values in all cells. Default values defined in the grid configuration on PHP side and stored in “template row” of the grid.
Parameters:
Category: Grid Data Handling
Returns:
This method shows a spinner (loading indicator) in the grid while an operation is in progress. You can call this method with a boolean argument to show or hide the spinner, or with a callback function that’s being executed when the spinner is shown.
Parameters:
Category: Grid Display
Returns:
Fills a row in the grid with data.
Parameters:
Category: Grid Data Handling
Returns:
Fills the grid with data.
Parameters:
Category: Grid Data Handling
Returns:
eiseGrid('dragNDrop', function(event){} ) method allows drag-n-drop operations on eiseGrid.
It shows the target over eiseGrid when user start drag over document body. When user finishes drag it removes the target.
Callback function is bound to ‘drop’ event over eiseGrid elements. Before the call grid shows the spinner.
Callback is called in the context of eiseGrid object, not the main <DIV> or jQuery object.
After you handle the updload with XHR or whatever you can call eiseGrid(‘fill’, [{…}, {…}] ) method to add some rows to the grid.
Parameters:
Category: Grid Data Handling
This function preforms AJAX file upload to the server and fills the grid with returned data. It is useful for grids that manage file attachments.
Parameters:
Category: Grid Data Handling
Returns:
This method helps to struggle with large amount of elements and PHP limits to handle them. This limit is set in max_input_vars php.ini setting and it is 1000 by default. eiseGrid(‘disableUnchanged’) disables inputs in the rows that wasn’t changed so browser doesn’t include its contents into POST. Keep your php.ini safe, call this method before your main form submits.
Returns: jQuery
Category: Grid Manipulation
This function retrieves data from the grid as an array of grid rows that represented as dictionaries of field values.
Parameters:
Category: Grid Data Handling
Returns: {Array} - array of grid rows represented as dictionaries of field values.
This function exports grid data to an Excel file.
Parameters:
Category: Grid Data Handling
Returns:
This function returns an object with row data in {xx: {v: , t: }}, pasteable to othe grid with fill() function
Parameters:
Category: Grid Data Handling
Returns: {Object} - object with row data in {xx: {v: , t: }}, pasteable to othe grid with fill() function
eiseGrid class constructor. Object of this class encapsulates all grid functionality. jQuery plugins are just wrappers around this class methods. See jQuery plugins documentation for details.
Category: Grid Display
Color the selected rows in the grid basing on the predefined colors in the grid configuration chosen by the user from the color picker dialog