Angular DataGrid Methods
addColumn(columnOptions)
The column's configuration or the data field for which the column should be created.
beginCustomLoading(messageText)
Shows the load panel.
Normally, the load panel is invoked automatically while the widget is busy rendering or loading data. Additionally, you can invoke it by calling this method. If you call it without the argument, the load panel displays text specified by the loadPanel.text option. To specify the appearance of the load panel, use the loadPanel object. Once invoked from code, the load panel will not hide until you call the endCustomLoading() method.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
beginUpdate()
Prevents the widget from refreshing until the endUpdate() method is called.
The beginUpdate() and endUpdate() methods prevent the widget from excessive updates when you are changing multiple widget settings at once. After the beginUpdate() method is called, the widget does not update its UI until the endUpdate() method is called.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
byKey(key)
A Promise that is resolved after the data object is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
The following code shows how to get a data object whose key is 15.
widgetInstance.byKey(15).done(function(dataObject) { // process "dataObject" }).fail(function(error) { // handle error });
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- instance()
cellValue(rowIndex, visibleColumnIndex, value)
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
clearFilter(filterName)
The method's parameter specifies what type of filter should be cleared. The parameter can have one of the following values:
- 'dataSource' - clears the dataSource filter (defined in the configuration or applied by the filter(filterExpr) method);
- 'search' - clears the search panel;
- 'header' - clears the column header filter;
- 'row' - clears the filter row.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
clearGrouping()
For more information about grouping, see the Grouping topic.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- Clear Grouping
clearSelection()
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- deselectAll()
- deselectRows(keys)
closeEditCell()
Switches the cell being edited back to the normal state. Takes effect only if editing.mode is batch and showEditorAlways is false.
collapseRow(key)
A Promise that is resolved after the row is collapsed. It is a native Promise or a jQuery.Promise when you use jQuery.
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.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- Expand and Collapse Groups - API
- Master-Detail Interface - API
columnOption(id)
This method gets the options of the first column found by either of the below:
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:"command:edit"
Gets the editing column."command:select"
Gets the selection column."command:adaptive"
Gets the adaptive column.Any string matching the following format: "optionName:value"
Here, the optionName is one of the column options.
See Also
columnOption(id, optionName)
This method gets the value of an option of the first column found by either of the below:
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:"command:edit"
Gets the editing column."command:select"
Gets the selection column."command:adaptive"
Gets the adaptive column.Any string matching the following format: "optionName:value"
Here, the optionName is one of the column options.
See Also
columnOption(id, optionName, optionValue)
This method sets an option of the first column found by either of the below:
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:"command:edit"
Gets the editing column."command:select"
Gets the selection column."command:adaptive"
Gets the adaptive column.Any string matching the following format: "optionName:value"
Here, optionName is one of the column options.
NOTEIn command columns, you can change only the width and the visibleIndex. See the Command Columns topic for details.
See Also
columnOption(id, options)
This method changes options of the first column found by either of the below:
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:"command:edit"
Gets the editing column."command:select"
Gets the selection column."command:adaptive"
Gets the adaptive column.Any string matching the following format: "optionName:value"
Here, optionName is one of the column options.
NOTEIn command columns, you can change only the width and the visibleIndex. See the Command Columns topic for details.
See Also
defaultOptions(rule)
defaultOptions is a static method that the widget class supports. The following code demonstrates how to specify default options for all instances of the DataGrid widget in an application executed on the desktop.
jQuery
DevExpress.ui.dxDataGrid.defaultOptions({ device: { deviceType: "desktop" }, options: { // Here go the DataGrid options } });
Angular
import DataGrid from 'devextreme/ui/data_grid'; // ... export class AppComponent { constructor () { DataGrid.defaultOptions({ device: { deviceType: "desktop" }, options: { // Here go the DataGrid options } }); } }
deleteColumn(id)
This method removes the first column found by either of the below:
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.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- addColumn(columnOptions)
- deleteRow(rowIndex)
deleteRow(rowIndex)
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- addRow()
- deleteColumn(id)
deselectAll()
A Promise that is resolved after the selection is cleared. It is a native Promise or a jQuery.Promise when you use jQuery.
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. The selection is cleared of only those rows that meet filtering conditions if a filter is applied. To clear selection regardless of the selectAllMode option's value or applied filters, call the clearSelection() method.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
deselectRows(keys)
Array<any>
A Promise that is resolved after selection is cleared. It is a native Promise or a jQuery.Promise when you use jQuery.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- Initial and Runtime Selection
- deselectAll()
dispose()
The following code disposes of an DataGrid instance that corresponds to the element ID (or reference variable in Angular) and removes the element from the DOM:
jQuery
$("#myDataGrid").dxDataGrid("dispose"); $("#myDataGrid").remove();
Angular
<dx-data-grid #dataGridVar id="myDataGrid"></dx-data-grid>
import { ..., ViewChild } from "@angular/core"; import { DxDataGridComponent } from "devextreme-angular"; // ... export class AppComponent { @ViewChild("dataGridVar") dataGrid: DxDataGridComponent; removeDataGrid (e) { this.dataGrid.instance.dispose(); document.getElementById("myDataGrid").remove(); } }
editCell(rowIndex, dataField)
Switches a cell with a specific row index and a data field to the editing state. Takes effect only if the editing mode is 'batch' or 'cell'.
editCell(rowIndex, visibleColumnIndex)
Switches a cell with specific row and column indexes to the editing state. Takes effect only if the editing mode is 'batch' or 'cell'.
editRow(rowIndex)
Switches a row with a specific index to the editing state. Takes effect only if the editing mode is 'row', 'popup' or 'form'.
endCustomLoading()
Hides the load panel.
Normally, the widget hides the load panel automatically once data 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.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
endUpdate()
Refreshes the widget after a call of the beginUpdate() method.
Main article: beginUpdate()
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
expandAdaptiveDetailRow(key)
To access a data row by its key, you should specify the field that provides keys in the data source. If no key was specified, the whole data object is considered the key.
See Also
expandAll(groupIndex)
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- Expand and Collapse Groups - API
- Master-Detail Interface - API
expandRow(key)
A Promise that is resolved after the row is expanded. It is a native Promise or a jQuery.Promise when you use jQuery.
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.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- Expand and Collapse Groups - API
- Master-Detail Interface - API
exportToExcel(selectionOnly)
For details on exporting, refer to the Client-Side Exporting article.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
filter()
Gets a filter expression applied to the widget's data source using the filter(filterExpr) method.
filter(filterExpr)
Pass an array with the following members to this method.
- The data source field by which data items are filtered.
- The comparison operator. The following operators are available: "=", "<>", ">", ">=", "<", "<=", "startswith", "endswith", "contains", "notcontains".
- The value with which data source field values should be compared.
This method applies a filter before the filter row, search panel, or header filter does. To clear all filters applied both from code and the UI, call the clearFilter() method.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- getCombinedFilter()
focus(element)
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- getCellElement(rowIndex, visibleColumnIndex)
getCellElement(rowIndex, dataField)
The cell's container. An HTML element or a jQuery element when you use jQuery. If the specified row or data field does not exist, the method returns undefined.
getCellElement(rowIndex, visibleColumnIndex)
The cell's container. An HTML element or a jQuery element when you use jQuery. If the specified row or column does not exist, the method returns undefined.
getCombinedFilter()
Use this method to get the total filter, which combines filters applied using the filter(filterExpr) method, filter row, header filter and the search panel. Note that the total filter contains getters. To get the total filter with data fields, call the getCombinedFilter(returnDataField) method.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
getCombinedFilter(returnDataField)
Use this method to get the total filter, which combines filters applied using the filter(filterExpr) method, filter row, header filter and the search panel.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- getCombinedFilter()
getInstance(element)
getInstance is a static method that the widget class supports. The following code demonstrates how to get the DataGrid instance found in an element with the myDataGrid
ID:
// Modular approach import DataGrid from 'devextreme/ui/data_grid'; ... let element = document.getElementById("myDataGrid"); let instance = DataGrid.getInstance(element) as DataGrid; // Non-modular approach let element = document.getElementById("myDataGrid"); let instance = DevExpress.ui.dxDataGrid.getInstance(element);
See Also
getRowElement(rowIndex)
Note that if the widget has fixed columns, the method returns an array of two separate elements: with unfixed and with fixed columns.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
getRowIndexByKey(key)
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- getKeyByRowIndex(rowIndex)
getScrollable()
For information on API members of the scrollable part, refer to the ScrollView section, but bear in mind that several members described there are unavailable. Those are the following.
Options:
- pullingDownText
- pulledDownText
- refreshingText
- reachBottomText
- onPullDown
- onReachBottom
Methods:
- release(preventScrollBottom)
- refresh()
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
getSelectedRowKeys()
The whole data object is considered a key if the field providing keys is not specified in the data source. In this case, this method returns data objects, that is, operates like the getSelectedRowsData() method.
Note that when selection is deferred, the method returns a Promise (a native Promise or a jQuery.Promise when you use jQuery) that should be resolved with an array of keys.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
getSelectedRowsData()
When selection is deferred, the method returns a Promise (a native Promise or a jQuery.Promise when you use jQuery) that should be resolved with an array of objects.
See Also
getVisibleColumns()
Visible columns; may include command columns.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- getVisibleColumns(headerLevel)
getVisibleColumns(headerLevel)
Gets all visible columns at a specific hierarchical level of column headers. Use it to access banded columns.
hasEditData()
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- saveEditData()
- cancelEditData()
isAdaptiveDetailRowExpanded(key)
To access a data row by its key, specify the field that provides keys in the data source. If no key was specified, the whole data object is considered the key.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- expandAdaptiveDetailRow(key)
- collapseAdaptiveDetailRow()
- columnHidingEnabled
isRowExpanded(key)
To check whether a group row is expanded, call this method with an array, in which each member is a grouping value. To check if a master row is expanded, pass its key to this method.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
isRowSelected(data)
Checks whether a row found using its data object is selected. Takes effect only if selection.deferred is true.
isRowSelected(key)
Checks whether a row with a specific key is selected. Takes effect only if selection.deferred is false.
pageCount()
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- Paging - API
pageIndex()
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.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- Paging - API
pageIndex(newIndex)
A Promise that is resolved after the page is shown. It is a native Promise or a jQuery.Promise when you use jQuery.
refresh()
A Promise that is resolved after data is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
The widget cannot track changes made in the data source by a third party. To bring data in the widget up to date in this case, call this method. Data sources of lookup columns will be updated along with the main data source.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
repaintRows(rowIndexes)
This method updates the row objects and their visual representation.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
saveEditData()
A Promise that is resolved after changes are saved in the data source. It is a native Promise or a jQuery.Promise when you use jQuery.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- cancelEditData()
- hasEditData()
- onRowInserted
- onRowUpdated
- onRowRemoved
searchByText(text)
Seeks a search string in the columns whose allowSearch option is true.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- getCombinedFilter()
- searchPanel
selectAll()
A Promise that is resolved after all rows are selected. It is a native Promise or a jQuery.Promise when you use jQuery.
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.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- Initial and Runtime Selection
- selectRows(keys, preserve)
- selection
selectRows(keys, preserve)
A Promise that is resolved after the rows are selected. It is a native Promise or a jQuery.Promise when you use jQuery.
By default, this method call clears selection of previously selected rows. To keep these rows selected, call this method with true as the second argument.
widgetInstance.selectRows([5, 10, 12], true);
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- Initial and Runtime Selection
- selectRowsByIndexes(indexes)
selectRowsByIndexes(indexes)
A Promise that is resolved after the rows are selected. It is a native Promise or a jQuery.Promise when you use jQuery.
This method has the following specifics:
- This method call clears selection of all previously selected rows.
- When calculating row indexes, the widget counts data and group rows. Nevertheless, only data rows can be selected.
- If the pager is used, selection is cleared once a user moves to a different page. To preserve it, call this method within the onContentReady handler.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- Initial and Runtime Selection
state()
The following example shows how to save the widget state in the local storage and load it from there:
jQuery
$(function () { var dataGrid = $("#dataGridContainer").dxDataGrid({ // ... }).dxDataGrid; $("#save").dxButton({ text: 'Save State', onClick: function() { var state = dataGrid.state(); // Saves the state in the local storage localStorage.setItem("dataGridState", JSON.stringify(state)); } }); $("#load").dxButton({ text: 'Load State', onClick: function() { let state = JSON.parse(localStorage.getItem("dataGridState")); dataGrid.state(state); } }); });
Angular
import { Component, ViewChild } from '@angular/core'; import { DxDataGridModule, DxButtonModule, DxDataGridComponent } from 'devextreme-angular'; // ... export class AppComponent { @ViewChild(DxDataGridComponent) DataGrid: DxDataGridComponent saveState() { let state = this.dataGrid.instance.state(); // Saves the state in the local storage localStorage.setItem("dataGridState", JSON.stringify(state)); } loadState() { let state = JSON.parse(localStorage.getItem("dataGridState")); this.dataGrid.instance.state(state); } } @NgModule({ imports: [ DxDataGridModule, DxButtonModule, // ... ], // ... })
<dx-data-grid ...> </dx-data-grid> <dx-button text="Save State" (onClick)="saveState()"> </dx-button> <dx-button text="Load State" (onClick)="loadState()"> </dx-button>
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- stateStoring
state(state)
See an example in the state() method.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- stateStoring
undeleteRow(rowIndex)
Recovers a row deleted in batch editing mode.
See Also
- Call Methods: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
- closeEditCell()
- cancelEditData()
If you have technical questions, please create a support ticket in the DevExpress Support Center.