Methods

This section describes the methods that can be used to manipulate the DataGrid widget.

addColumn(columnOptions)

Adds a new column to a grid.

Parameters:
columnOptions:

Object

|

String

The options of the added column or the name of a data field.

To add a column to a grid, call the addColumn(columnOptions) method of the grid instance. Pass the options of the added column as the columnOptions argument. Refer to the columns option description for the full list of available options.

There may be cases, when no options, except the dataField, are required to be specified. In this instance, pass the name of the data field as the argument to the addColumn(columnOptions) method instead of the object with column options.

addRow()

Adds a new data row to a grid.

To learn more about how to insert a new row from code, see the Insertion paragraph of the Editing in Code topic.

beginCustomLoading(messageText)

Displays the load panel.

Parameters:
messageText:

String

Text to be displayed in the load panel.

Normally, DataGrid displays a load panel automatically when it is busy rendering or loading data. Additionally, the load panel can be invoked when required by calling the beginCustomLoading(messageText) method. If you call this method without the argument, the load panel displays text specified by the loadPanel | text option. To specify the appearance of the load panel, use the properties of the loadPanel configuration object.

Once invoked in code, the load panel will not hide until the endCustomLoading() method is called.

NOTE
The load panel invoked in code does not replace the automatically invoked load panel. This circumstance might lead to a situation where the load panel invoked in code suddenly changes its text because it was overridden by the automatically invoked load panel. Hence, be mindful when invoking the load panel with different text.

beginUpdate()

Prevents the component from refreshing until the endUpdate() method is called.

The beginUpdate() and endUpdate() methods allow you to apply several modifications to the component. After the beginUpdate() method is called, the component does not update the UI until the endUpdate() method is called. The usage of these methods prevents excessive component updating when you are changing multiple component settings at once.

byKey(key)

Allows you to obtain a data object by its key.

Parameters:
key:

Object

|

String

|

Number

The key value of the required data object.

Return Value:

jQuery.Promise

A Promise of the jQuery.Deferred object resolved after the data object has been loaded.

The following code snippet demonstrates how to get a data object whose key equals 15.

JavaScript
dataGridInstance.byKey(15).done(function(dataObject) {
        // process 'dataObject'
    }).fail(function(error) {
        // handle error
    });

cancelEditData()

Discards changes made in a grid.

To learn how to manage the editing process from code, see the Editing in Code topic.

cellValue(rowIndex, dataField)

Gets the cell value.

Parameters:
rowIndex:

Number

The index of the row to which the cell belongs.

dataField:

String

The name of the data field in the dataSource.

Return Value: any

The cell value.

cellValue(rowIndex, dataField, value)

Sets the cell value.

Parameters:
rowIndex:

Number

The index of the row to which the cell belongs.

dataField:

String

The name of the data field in the dataSource.

value: any

The new value of the cell.

cellValue(rowIndex, visibleColumnIndex)

Gets the cell value.

Parameters:
rowIndex:

Number

The index of the row to which the cell belongs.

visibleColumnIndex:

Number

The current index of the column to which the cell belongs.

Return Value: any

The cell value.

cellValue(rowIndex, visibleColumnIndex, value)

Sets the cell value.

Parameters:
rowIndex:

Number

The index of the row to which the cell belongs.

visibleColumnIndex:

Number

The current index of the column to which the cell belongs.

value: any

The new value of the cell.

If the editing mode is not 'cell', call the saveEditData() method to save changes.

clearFilter()

Clears all filters applied to grid rows.

clearFilter(filterName)

Clears all filters of a specific type applied to grid rows.

Parameters:
filterName:

String

Type of filter to be cleared.

In the DataGrid, rows can be filtered in several different ways. The method's parameter specifies what type of filter should be cleared. The parameter values can be the following:

clearGrouping()

Ungroups grid records.

For more information about grouping, see the Grouping topic.

clearSelection()

Clears selection of all grid rows on all pages.

clearSorting()

Clears sorting settings of all grid columns at once.

For more information about sorting in DataGrid, see the Sorting topic.

closeEditCell()

Draws the cell being edited from the editing state. Use this method when the edit mode is batch.

To learn how to manage the editing process from code, see the Editing in Code topic.

collapseAdaptiveDetailRow()

Collapses the currently expanded adaptive detail row (if there is one).

See Also

collapseAll(groupIndex)

Collapses groups or master rows in a grid.

Parameters:
groupIndex:

Number

| undefined

The index of the groups to collapse. Pass undefined to collapse all groups. Pass -1 to collapse all master rows.

Learn more from the Expanding and Collapsing Groups topic.

collapseRow(key)

Allows you to collapse a specific group or master row by its key.

Parameters:
key: any

The key of the group or master row.

To collapse a group row, call this method with an array each member of which is a grouping value. To collapse a master row, pass its key to this method.

columnCount()

Returns the number of data columns in a grid.

Return Value:

Number

The number of data columns in a grid.

The columnCount() method returns the number of columns currently presented in a grid. This number includes visible and hidden columns, but omits the selection and editing columns.

columnOption(id)

Returns the options of a column by an identifier.

Parameters:
id:

Number

|

String

The name, index, data field, or caption of a column.

Return Value:

Object

The options of the specified column.

Use this method to obtain an object of the options currently applied to a specific column. This method accepts one of the following.

  • Name
    The unique name of the column.

  • Column Index
    The index of the column in the columns array.

  • Data Field
    The name of the data source field assigned to the column.

  • Caption
    The text displayed in the column header.

  • Service String
    One of the following values:

The options of the first column matching the name, column index, data field, caption or service string will be returned by this method.

For the list of options included in the object returned by the columnOption(id) method, refer to the columns option description. Additionally, you can get the value of a specific column option using the same method called with two arguments.

columnOption(id, optionName)

Returns the value of a specific column option.

Parameters:
id:

Number

|

String

The name, index, data field or caption of a column.

optionName:

String

The name of the required option.

Return Value: any

The value of the specified option.

Use this method to obtain the value of a specific column option. This method accepts one of the following as the first argument.

  • Name
    The unique name of the column.

  • Column Index
    The index of the column in the columns array.

  • Data Field
    The name of the data source field assigned to the column.

  • Caption
    The text displayed in the column header.

  • Service String
    One of the following values:

The specified option of the first column matching the name, column index, data field, or caption will be returned by this method.

For the list of accessible options, refer to the columns option description. Additionally, you can get all options of a specific column by calling the same method with an identifier only.

columnOption(id, optionName, optionValue)

Sets an option of a specific column.

Parameters:
id:

Number

|

String

The name, index, data field, or caption of a column.

optionName:

String

The name of the option to change.

optionValue: any

A new value for this option.

Using this method, you can set an option of a specific column from code. This method accepts one of the following as the first argument.

  • Name
    The unique name of the column.

  • Column Index
    The index of the column in the columns array.

  • Data Field
    The name of the data source field assigned to the column.

  • Caption
    The text displayed in the column header.

  • Service String
    One of the following values:

    NOTE
    In command columns, you can change only the width or the visibleIndex.

The specified option of the first column matching the name, column index, data field or caption will be changed by this method.

For the list of accessible options, refer to the columns option description. Also, you can set several column options at once. Use the columnOption(id, options) method to do this.

columnOption(id, options)

Sets several options of a column at once.

Parameters:
id:

Number

|

String

The name, index, data field,or caption of a column.

options:

Object

The required configuration options.

Using this method, you can set several options of a specific column from code. This method accepts one of the following as the first parameter.

  • Name
    The unique name of the column.

  • Column Index
    The index of the column in the columns array.

  • Data Field
    The name of the data source field assigned to the column.

  • Caption
    The text displayed in the column header.

  • Service String
    One of the following values:

    NOTE
    In command columns, you can change only the width or the visibleIndex.

The options of the first column matching the name, column index, data field or caption will be changed by this method.

For the list of accessible options, refer to the columns option description. If you need to set only one option for a column, you can use the columnOption(id, optionName, optionValue) method instead.

defaultOptions(rule)

Specifies the device-dependent default configuration options for this component.

Parameters:
rule:

Object

An object specifying default options for the component and the device for which the options must be applied.

Object structure:
device:

Object

|

Array

|

function

An object representing device parameters, or an array of objects representing device parameters, or a function that provides information on the current device as an input parameter and returning a Boolean value.

options:

Object

A configuration object with specified options.

The defaultOptions method is a static method supported by the widget class. The following code demonstrates how to specify default options for all buttons in the application executed on the iOS platform.

JavaScript
DevExpress.ui.dxButton.defaultOptions({ 
    device: { platform: "ios" },
    options: {
        text: "Click me"
    }
});

deleteColumn(id)

Removes the column from the grid.

Parameters:
id:

Number

|

String

The current column index or the name of the data field in the dataSource.

deleteRow(rowIndex)

Removes a specific row from a grid.

Parameters:
rowIndex:

Number

The index of the row to be removed.

To learn more about how to remove a row from code, see the Removing paragraph of the Editing in Code topic.

deselectAll()

Clears selection of all grid rows on the current page only or on all pages.

Return Value:

jQuery.Promise

A Promise of the jQuery.Deferred object resolved after the grid has cleared selection of rows.

Depending on the value of the selectAllMode option, this method clears selection of all rows on all pages or on the currently rendered pages only. If any filter is also applied, this method clears selection of only those rows that meet the filtering conditions.

If you need to clear selection of all grid rows regardless of the value of the selectAllMode option, use the clearSelection() method.

deselectRows(keys)

Clears selection of specified grid rows.

Parameters:
keys:

Array

The keys of rows whose selection should be cleared.

Return Value:

jQuery.Promise

A Promise of the jQuery.Deferred object resolved after the grid has cleared selection of the specified rows.

To access a grid row by a key, a field providing key values must be specified in a data source. If no key was specified, the whole data object is considered the key.

See Also

editCell(rowIndex, dataField)

Sets a specific cell into the editing state.

Parameters:
rowIndex:

Number

The index of a row holding the cell that should enter the editing state.

dataField:

String

The name of the data field in the dataSource.

To learn how to manage the editing process from code, see the Editing in Code topic.

editCell(rowIndex, visibleColumnIndex)

Sets a specific cell into the editing state.

Parameters:
rowIndex:

Number

The index of a row holding the cell that should enter the editing state.

visibleColumnIndex:

Number

The current index of a column holding the cell that should enter the editing state.

To learn how to manage the editing process from code, see the Editing in Code topic.

editRow(rowIndex)

Sets a specific row into the editing state.

Parameters:
rowIndex:

Number

The index of a row that should enter the editing state.

To learn how to manage the editing process from code, see the Editing in Code topic.

element()

Returns the root HTML element of the widget.

Return Value:

jQuery

The root element of the widget.

endCustomLoading()

Hides the load panel.

Normally, a load panel in DataGrid is hidden automatically when the widget is ready. But if you have invoked the load panel from code using the beginCustomLoading(messageText) method, you must call the endCustomLoading() method to hide it.

endUpdate()

Enables the component to refresh after the beginUpdate() method call.

The beginUpdate() and endUpdate() methods allow you to apply several modifications to the component. After the beginUpdate() method is called, the component does not update the UI until the endUpdate() method is called. The usage of these methods prevents excessive component updating when you change multiple component setting at once.

expandAdaptiveDetailRow(key)

Expands an adaptive detail row by the key of its parent data row.

Parameters:
key: any

The key of a data row.

NOTE
To access a data row by its key, a field providing key values must be specified in a data source. If no key was specified, the whole data object is considered the key.
See Also

expandAll(groupIndex)

Expands groups or master rows in a grid.

Parameters:
groupIndex:

Number

| undefined

The index of the groups to expand. Pass undefined to expand all groups. Pass -1 to expand all master rows.

Learn more from the Expanding and Collapsing Groups topic.

NOTE
This method cannot be called if you use a remote data source.

expandRow(key)

Allows you to expand a specific group or master row by its key.

Parameters:
key: any

The key of the group or master row.

To expand a group row, call this method with an array (each member of which is a grouping value). To expand a master row, pass its key to this method.

exportToExcel(selectionOnly)

Exports grid data to Excel.

Parameters:
selectionOnly:

Boolean

Specifies whether to export all the data presented in the grid or the selected rows only.

For details on exporting, refer to the Client-Side Export article.

filter()

Returns a filter expression applied to the grid's data source using the filter(filterExpr) method.

Return Value: any

You can get a total filter summarized from all possible filters:

For this purpose, use the getCombinedFilter() method.

filter(filterExpr)

Applies a filter to the grid's data source.

Parameters:
filterExpr: any

This method filters grid records in code. Pass an array with the following members to this method.

  1. The data source field by which data items are filtered.
  2. The comparison operator. The following operators are available: "=", "<>", ">", ">=", "<", "<=", "startswith", "endswith", "contains", "notcontains".
  3. The value with which data source field values should be compared.

The filters specified by end users using a filter row, a column's header filter or the search panel are applied to the data source that is already filtered using the filter(filterExpr) method. To clear all the filters applied to the grid both in code and by end users, call the clearFilter() method.

See Also

View Demo

focus()

Sets focus on the widget.

focus(element)

Focuses the specified cell element in the grid.

Parameters:
element:

jQuery

The cell element to be focused.

To get the element of the required cell, use the getCellElement(rowIndex, visibleColumnIndex) method, passing the column and row that identify the target cell.

getCellElement(rowIndex, dataField)

Allows you to obtain a cell by its row index and the data field of its column.

Parameters:
rowIndex:

Number

The row index of the cell.

dataField:

String

The data field of the cell's column.

Return Value:

jQuery

| undefined

The cell element; provides access to element-related jQuery operations.

getCellElement(rowIndex, visibleColumnIndex)

Allows you to obtain a cell by its row index and the visible index of its column.

Parameters:
rowIndex:

Number

The row index of the cell.

visibleColumnIndex:

Number

The visible index of the cell's column. Find out how to calculate this index in the Calculating the Column Index topic.

Return Value:

jQuery

| undefined

The cell element; provides access to element-related jQuery operations.

getCombinedFilter()

Returns a filter expression applied to the grid using all possible scenarios.

Return Value: any

The DataGrid can be filtered both in code, using the filter(fitlerExpr) method, and in the UI, using a filter row, a column's header filter or the search panel. To get a total filter summarized from all the filters applied, use the getCombinedFilter() method.

Note that this method returns filter expressions with the getters. If you want to obtain filter expressions with data fields, use the getCombinedFilter(returnDataField) method.

getCombinedFilter(returnDataField)

Returns a filter expression applied to the grid using all possible scenarios.

Parameters:
returnDataField:

Boolean

Specifies whether or not the filter expressions should contain data fields instead of getters.

Return Value: any

The DataGrid can be filtered both in code, using the filter(fitlerExpr) method, and in the UI, using a filter row, a column's header filter or the search panel. To get a total filter summarized from all the filters applied, use the getCombinedFilter(returnDataField) method.

getDataSource()

Allows you to get the DataSource instance.

Return Value:

DataSource

getKeyByRowIndex(rowIndex)

Allows you to obtain the data key by a row index.

Parameters:
rowIndex:

Number

The visible row index.

Return Value: any

The data key of the row. If nothing found, returns undefined.

DataGrid's API comprises a great number of methods, some of which accept data keys as their arguments while the others accept row indexes. If you have a row index, you can obtain the respective data key by calling the getKeyByRowIndex(rowIndex) method. And vice versa as well, if you have a data key, you can obtain the respective row index by calling the getRowIndexByKey(key) method. For information on how row indexes are calculated in DataGrid, refer to the Grid Rows article.

getRowElement(rowIndex)

Allows you to obtain a row element by its index.

Parameters:
rowIndex:

Number

The visible index of the row.

Return Value:

jQuery

| undefined

The row element; provides access to element-related jQuery operations.

Note that if the DataGrid has fixed columns, the method returns two row elements: the first with columns that are not fixed, the second with fixed columns.

getRowIndexByKey(key)

Allows you to obtain the row index by a data key.

Parameters:
key:

Object

|

String

|

Number

The data key of a row in the store.

Return Value:

Number

The visible row index. If nothing found, returns -1.

DataGrid's API comprises a great number of methods, some of which accept data keys as their arguments while the others accept row indexes. If you have a data key, you can obtain the respective row index by calling the getRowIndexByKey(key) method. And vice versa as well, if you have a row index, you can obtain the respective data key by calling the getKeyByRowIndex(rowIndex) method. For information on how row indexes are calculated in DataGrid, refer to the Grid Rows article.

getScrollable()

Gets an instance of the scrollable part of the DataGrid widget.

Return Value:

Scrollable

An instance of the scrollable part of the DataGrid.

An instance of the scrollable part is similar to the ScrollView, but its functionality is more specific.

The following options and methods are not available for the scrollable part of the DataGrid.

Options:

  • pullingDownText
  • pulledDownText
  • refreshingText
  • reachBottomText
  • onPullDown
  • onReachBottom

Methods:

  • release(preventScrollBottom)
  • refresh()

getSelectedRowKeys()

Gets the keys of currently selected grid records.

Return Value:

Array

|

jQuery.Promise

The array of keys of the currently selected records or a Promise of the jQuery.Deferred object.

If a field providing key values is not specified in a data source, the whole data object is considered the key. In this case, the getSelectedRowKeys() method returns data objects corresponding to the selected records, thus operating exactly as the getSelectedRowsData() method.

Note that when selection is deferred, the method returns a Promise of the jQuery.Deferred object that should be resolved with an array of keys.

See Also

getSelectedRowsData()

Gets data objects of currently selected rows.

Return Value:

Array

|

jQuery.Promise

Data objects of currently selected rows.

When selection is deferred, the method returns a Promise of the jQuery.Deferred object that should be resolved with an array of objects.

NOTE
Calculated values cannot be obtained because this method gets data objects directly from the data source.

View Demo

See Also

getTotalSummaryValue(summaryItemName)

Gets the value of a total summary item.

Parameters:
summaryItemName:

String

The name of the total summary item.

Return Value: any

The automatically calculated value of the total summary item.

getVisibleColumns()

Gets an array of visible columns.

Return Value:

Array

An array of visible columns.

This method returns an array of objects that contain configuration options of visible columns. The array may include columns with data and command columns.

To obtain information about visible columns at a specific hierarchical level of column headers, including band columns, use the getVisibleColumns(headerLevel) method.

getVisibleColumns(headerLevel)

Gets an array of visible columns at a specific hierarchical level of column headers.

Parameters:
headerLevel:

Number

The level of column headers.

Return Value:

Array

An array of visible columns.

Use this method when the grid has band columns.

This method returns an array of objects that contain configuration options of visible columns. The array may include columns with data, command columns and band columns.

getVisibleRows()

Gets an array of visible rows.

Return Value:

Array

An array of visible rows.

hasEditData()

Checks whether or not the grid contains unsaved changes.

Return Value:

Boolean

Returns true if the grid contains any unsaved changes.

This method is a part of the Editing feature. Refer to the Guides section to learn more about how to use it.

hideColumnChooser()

Hides the column chooser panel.

This method hides the column chooser panel. To invoke it from code, use the showColumnChooser() method.

insertRow()

Deprecated

Use the addRow() method instead.

Adds a new data row to a grid.

To learn more about how to insert a new row from code, see the Insertion paragraph of the Editing in Code topic.

instance()

Returns an instance of this component class.

Return Value:

Object

An instance of this component class

Use this method to access other methods of the component.

isAdaptiveDetailRowExpanded(key)

Checks whether a specific adaptive detail row is expanded or collapsed.

Parameters:
key: any

The key of a data row.

NOTE
To access a data row by its key, a field providing key values must be specified in a data source. If no key was specified, the whole data object is considered the key.
See Also

isRowExpanded(key)

Allows you to find out whether a specific group or master row is expanded or collapsed.

Parameters:
key: any

The key of the group or master row.

Return Value:

Boolean

true if the row is expanded; false if collapsed.

To find out whether a group row is expanded, call this method with an array, in which each member is a grouping value. To find out if a master row is expanded, pass its key to this method.

isRowSelected(data)

Allows you to find out whether or not the row with a specified data object is selected.

Parameters:
data: any

The data object of the row.

Return Value:

Boolean

true if the row is selected; false otherwise.

NOTE
This method applies only if selection is deferred.
See Also

isRowSelected(key)

Allows you to find out whether or not the row with a specified key is selected.

Parameters:
key: any

The key of the row.

Return Value:

Boolean

true if the row is selected; false otherwise.

NOTE
This method applies only if selection is instant.

keyOf(obj)

Returns the key corresponding to the passed data object.

Parameters:
obj:

Object

A data object.

Return Value: any

The key of the passed data object.

If a field providing key values is not specified in a data source, the whole data object is considered the key. In this case, the keyOf(obj) method returns its argument.

off(eventName)

Detaches all event handlers from the specified event.

Parameters:
eventName:

String

The name of the event to unsubscribe from.

Return Value:

Object

The object for which this method is called.

off(eventName, eventHandler)

Detaches a particular event handler from the specified event.

Parameters:
eventName:

String

The name of the event to unsubscribe from.

eventHandler:

function

The handler to be detached from the specified event.

Return Value:

Object

The object for which this method is called.

on(eventName, eventHandler)

Subscribes to a specified event.

Parameters:
eventName:

String

The name of the event to be subscribed.

eventHandler:

function

An event handler for the specified event.

Return Value:

Object

The object for which this method is called.

Use this method to subscribe to one of the events listed in the Events section.

See Also

on(events)

Subscribes to the specified events.

Parameters:
events:

Object

An object of the following structure: { "eventName1": handler1, "eventName2": handler2, ...}

Return Value:

Object

The object for which this method is called.

Use this method to subscribe to several events at one method call. Available events are listed in the Events section.

See Also

option()

Returns the configuration options of this component.

Return Value:

Object

An object representing the configuration options of this component.

option(optionName)

Gets the value of the specified configuration option of this component.

Parameters:
optionName:

String

The name of the option to get.

Return Value: any

The value of the specified option.

If you need to get the value of a configuration option field, specify the path to the required field.

option(optionName, optionValue)

Sets a value to the specified configuration option of this component.

Parameters:
optionName:

String

The name of the required option.

optionValue: any

The value you wish to assign to the required option.

To set a value to the configuration option field, specify the path to the required field.

option(options)

Sets one or more options of this component.

Parameters:
options:

Object

An object containing the required configuration options.

pageCount()

Returns how many pages the grid contains.

Return Value:

Number

The number of pages in the grid.

NOTE
If you use infinite scrolling, this method returns how many pages the grid has loaded up until now.

pageIndex()

Gets the index of the current page.

Return Value:

Number

The index of the current page.

When using the pager, this method returns a value that is one less than the number of the current page.

When using scrolling in a virtual or infinite mode, this method return the index of the page whose record is displayed first in the grid.

pageIndex(newIndex)

Switches a grid to a specified page.

Parameters:
newIndex:

Number

The index of the page to switch to.

This method allows you to switch between pages without using the pager or scrolling. Note that the page index, which is passed as the argument to the pageIndex(newIndex) method, is one number less than the page number.

pageSize()

Gets the current page size.

Return Value:

Number

The current page size.

To specify the page size when configuring the DataGrid widget, use the paging | pageSize property.

pageSize(value)

Sets the page size.

Parameters:
value:

Number

A new value of the page size.

To specify the page size when configuring the DataGrid widget, use the paging | pageSize property.

refresh()

Refreshes grid data.

Return Value:

jQuery.Promise

A Promise of the jQuery.Deferred object resolved after grid data has been refreshed.

When you use a data source that is changing dynamically, the DataGrid widget cannot automatically track changes that might be made in the source by a third party. In this case, to update data in the widget, call its refresh() method. Along with the main data source, a call of this method refreshes data sources of lookup columns if there are any in the grid.

NOTE
Calling the refresh() method concludes the editing process. In the row edit mode, all changes made in a row (if any) vanish. In the batch edit mode, changes are saved in a buffer waiting to be actually saved in the data source.

removeRow(rowIndex)

Deprecated

Use the deleteRow(rowIndex) method instead.

Removes a specific row from a grid.

Parameters:
rowIndex:

Number

The index of the row to be removed.

To learn more about how to remove a row from code, see the Removing paragraph of the Editing in Code topic.

repaint()

Redraws the widget.

After performing some external modifications that lead to a change of the widget container's size or visibility, the widget's state may become invalid. In this instance, use the repaint() method to redraw the widget.

repaintRows(rowIndexes)

Redraws the specified rows.

Parameters:
rowIndexes:

Array

An array of row indexes.

NOTE
This method updates the objects of the specified rows and their visual representation.

saveEditData()

Saves changes made in a grid.

Return Value:

jQuery.Promise

A Promise of the jQuery.Deferred object resolved after changes made in the grid have been saved in the data source.

To learn how to manage the editing process from code, see the Editing in Code topic.

searchByText(text)

Searches grid records by a search string.

Parameters:
text:

String

A search string.

This method searches grid records by a search string. This string is searched in those grid columns that have the allowFiltering option set to true. To clear search results, call the searchByText(text) method with an empty string as the argument.

Additionally, a user might be able to search records using a search panel. The panel is hidden by default. To make it visible, assign true to the searchPanel | visible property.

selectAll()

Selects all rows.

Return Value:

jQuery.Promise

A Promise of the jQuery.Deferred object resolved after the grid has selected all rows.

Depending on the value of the selectAllMode option, this method selects all rows on all pages or on the currently rendered pages only. If a filter is applied, this method selects only those rows that meet the filtering conditions.

View Demo

See Also

selectRows(keys, preserve)

Selects specified grid rows.

Parameters:
keys:

Array

The keys of the rows to be selected.

preserve:

Boolean

Specifies whether or not previously selected rows must remain selected.

Return Value:

jQuery.Promise

A Promise of the jQuery.Deferred object resolved after the grid has selected the specified rows.

NOTE
To access a grid row by a key, a field providing key values must be specified in the key option of the underlying Store of the dataSource. If no key was specified, the whole data object is considered the key, however, we recommend specifying the key to prevent selection from being duplicated.

By default, calling the selectRows(keys, preserve) method deselects all previously selected rows. If you need these rows to remain selected, call the same method with true as its second argument as the code snippet below demonstrates.

JavaScript
dataGridInstance.selectRows([5, 10, 12], true);

View Demo

selectRowsByIndexes(indexes)

Selects grid rows by indexes.

Parameters:
indexes:

Array

The indexes of rows to be selected.

Return Value:

jQuery.Promise

A Promise of the jQuery.Deferred object resolved after the grid has selected the specified rows.

An array that is passed to this method as an argument must contain row indexes. When calculating them, data and group rows are counted, though only data rows can be selected.

Note that if the pager is used for navigating through pages, selection applied by the selectRowsByIndexes(indexes) method will be cleared once the user moves to a different page. Therefore, to preserve the selection, call this method within the onContentReady callback function.

If the virtual scrolling mode is used, row indexes are rendered only for pages that have been visible. So, it is impossible to select a row on a page, that has not been visible using this method.

NOTE
Calling the selectRowsByIndexes(indexes) method deselects all previously selected rows.

showColumnChooser()

Invokes the column chooser panel.

This method invokes the column chooser panel. To hide it from code, use the hideColumnChooser method.

state()

Returns the current state of the grid.

Return Value:

Object

An opaque data object presenting the grid state.

For more information about working with the grid state, refer to the stateStoring option description.

state(state)

Sets the grid state.

Parameters:
state:

Object

An opaque data object presenting the grid state.

For more information about working with the grid state, refer to the stateStoring option description.

totalCount()

Returns the number of records currently held by a grid.

Return Value:

Number

The number of records currently held by a grid.

Use this method to get the number of records currently held by a grid. Note that if records are filtered by a user using the filter row and search panel or from code using the filter(filterExpr) and searchByText(text) methods, the totalCount() method returns the number of records left after filtering.

undeleteRow(rowIndex)

Recovers a row deleted in the batch edit mode.

Parameters:
rowIndex:

Number

The index of the row to recover.

To learn more about how to recover a deleted row programmatically, see the Removing paragraph of the Editing in Code topic.

updateDimensions()

Updates the grid to the size of its content.

Use this method to update the position of grid contents after the grid element was resized.