command
Fired before any other events. Can be canceled.
If the e.cancel
property is set to true
, the corresponding command is cancelled, the action is stopped and no other event is fired.
The following arguments are always passed:
- e.commandName - the name of the executing command
- e.cancel - sets whether the command will be cancelled
The following parameters are passed depending on commands:
-
"expandButtonCreate" - fired just before the detail toggle (expand/collapse) button is created.
item
- the corresponding data source item.
-
"exportExcel" - fired when export to excel is initialized
exportOptions
- the exportOptions object containing the settings for this export. Can be overriden
-
"exportExcelRow" - fired when a row from the Grid is added to the list of rows exported to Excel
item
- the corresponding data source item.index
- the zero-based index of the data source item.row
- the custom row options for the current row. Updates of this structure will affect the exported data.
-
"exportPdf" - fired when export to PDF is initialized
exportOptions
- the exportOptions object containing the settings for this export. Can be overriden
-
"exportPdfRow" - fired when a row from the Grid is added to the list of rows to be exported to PDF
item
- the corresponding data source item.index
- the zero-based index of the data source item.row
- the custom row options for the current row. Updates of this structure will affect the exported data.
-
"exportCsv" - fired when export to CSV is initialized
exportOptions
- the exportOptions object containing the settings for this export. Can be overriden
-
"exportCsvRow" - fired when a row from the Grid is added to the list of rows to be exported to CSV
item
- the corresponding data source item.index
- the zero-based index of the data source item.row
- the custom row options for the current row. Updates of this structure will affect the exported data.
-
"detailCreated"
detailCell
- the corresponding detailed item’s cell.item
- the corresponding data source item.
-
"selectionChanged"
toBeSelected
- a list of rows or cells which will be selectedviewIndices
- a list of view indices of the selected rowsindices
- a list of data indices of the selected rows.
-
"sort"
column
- the column which will be sorted.desc
- whether the sort order is descending.unsort
- whether the column will be unsorted.
-
"columnReorder"
index
- the old column indexnewIndex
- the new column indexcancel
- a flag indicating if the operation should be cancelled. Set this totrue
to cancel the reordering.
-
"columnResize"
field
- the column fieldwidth
- the new column widthcancel
- a flag indicating if the operation should be cancelled. Set this totrue
to cancel the resizing.
-
"cancel" - fired when button from columns or toolbar with command name “cancel” is clicked.
rowIndex
- the of the row from which cancel button is clicked.cell
- the cell which was in edit mode. Applicable when cell edit mode is enabled.
-
"edit" - fired when row or cell are about to be put in edit mode.
row
- the row which is in edit modecell
- cell which is in edit mode. Applicable when cell editing is enabled.index
- the zero-based index of the data item. Can be passed to the dataItem function to retrieve it.
- "insert" - fired when button from the toolbar with command name “insert” is clicked and new row is added to the grid.
- "save" - fired when save operation of the data source is performed.
-
"delete" - fired column’s button with command name “delete” is clicked.
rowIndex
- the row index which will be deleted.
-
"groupsReorder" - fired when groups in header group item are reordered and the grid is regrouped.
index
- the old group index.newIndex
- the new group index
-
"group" - fired when group is added to the grid
index
- the new group index.field
- the field by which grid is grouped.
-
"ungroup" - fired when group is removed from the grid
field
- the field by which grid is ungrouped.
$("#grid").shieldGrid({ dataSource: { data: [ { ID: 1, name: "name1" }, { ID: 2, name: "name2" } ] }, columns: [ { field: "ID" }, { field: "name" } ], events: { command: function (e) { if (e.commandName == "selectionChanged") { // array with all elements which will be selected var toBeSelected = e.toBeSelected; e.cancel = true; } if (e.commandName == "dataBound") { e.cancel = true; } if (e.commandName == "sort") { e.cancel = true; var column = e.column; var isDescending = e.desc; var isUnsort = e.unsort; } if (e.commandName == "detailCreated") { e.cancel = true; var detailsCell = e.detailCell; var item = e.item; } if (e.commandName == "cancel") { e.cancel = true; var rowIndex = e.rowIndex; var cell = e.cell; } if (e.commandName == "edit") { e.cancel = true; var row = e.row; var cell = e.cell; } if (e.commandName == "insert") { e.cancel = true; } if (e.commandName == "save") { e.cancel = true; } if (e.commandName == "edit") { e.cancel = true; var rowIndex = e.rowIndex; } if (e.commandName == "groupsReorder") { e.cancel = true; var newIndex = e.newIndex; } if (e.commandName == "group") { e.cancel = true; var field = e.field; } if (e.commandName == "ungroup") { e.cancel = true; var field = e.field; } } });