DataGrid

The DataGrid is a widget that represents data from a local or remote source in the form of a grid. This widget offers such basic features as sorting, grouping, filtering, as well as more advanced capabilities, like state storing, export to Excel, master-detail interface, and many others.

Included in: dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/data_grid
Export: default
DataGrid interactive configuration
Copy Code
Copy to Codepen
$("#datagrid").dxDataGrid({
});

                    

DevExtreme widgets are integrated with many popular libraries and frameworks. See the Installation section (for JavaScript libraries) or the Prerequisites and Installation section (for ASP.NET MVC framework) to find details on setting up DevExtreme with a particular library or framework.

The following code shows how to create the DataGrid widget using every supported library and framework. For more details on working with widgets in these libraries and frameworks, see the Widget Basics topic for jQuery, Angular, AngularJS, Knockout or ASP.NET MVC.

jQuery
JavaScript
HTML
$(function () {
    $("#dataGrid").dxDataGrid({
        dataSource: [{
            ID: 1,
            CompanyName: "Super Mart of the West",
            City: "Bentonville",
            State: "Arkansas"
        }, {
            ID: 2,
            CompanyName: "Electronics Depot",
            City: "Atlanta",
            State: "Georgia"
        }],
        keyExpr: "ID",
        columns: ['CompanyName', 'City', 'State']
    });
});
<div id="dataGrid"></div>
Angular
HTML
TypeScript
<dx-data-grid 
    [dataSource]="customers"
    keyExpr="ID">            
    <dxi-column dataField="CompanyName"></dxi-column>
    <dxi-column dataField="City"></dxi-column>
    <dxi-column dataField="State"></dxi-column>
</dx-data-grid>
import { DxDataGridModule } from 'devextreme-angular';
// ...
export class AppComponent {
    customers = [{
        ID: 1,
        CompanyName: "Super Mart of the West",
        City: "Bentonville",
        State: "Arkansas"
    }, {
        ID: 2,
        CompanyName: "Electronics Depot",
        City: "Atlanta",
        State: "Georgia"
    }];
}
@NgModule({
    imports: [
        // ...
        DxDataGridModule
    ],
    // ...
})
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-data-grid="{
        dataSource: customers,
        keyExpr: 'ID',
        columns: ['CompanyName', 'City', 'State']
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller("DemoController", function ($scope) {
        $scope.customers = [{
            ID: 1,
            CompanyName: "Super Mart of the West",
            City: "Bentonville",
            State: "Arkansas"
        }, {
            ID: 2,
            CompanyName: "Electronics Depot",
            City: "Atlanta",
            State: "Georgia"
        }];
    });
Knockout
HTML
JavaScript
<div data-bind="dxDataGrid: {
    dataSource: customers,
    keyExpr: 'ID',
    columns: ['CompanyName', 'City', 'State']
}"></div>
var viewModel = {
    customers: [{
        ID: 1,
        CompanyName: "Super Mart of the West",
        City: "Bentonville",
        State: "Arkansas"
    }, {
        ID: 2,
        CompanyName: "Electronics Depot",
        City: "Atlanta",
        State: "Georgia"
    }]
};
ko.applyBindings(viewModel);
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().DataGrid()
    .ID("dataGrid")
    .DataSource(new[] {
        new { 
            ID = 1,
            CompanyName = "Super Mart of the West",
            City = "Bentonville",
            State = "Arkansas" 
        }, 
        new {
            ID = 2,
            CompanyName = "Electronics Depot",
            City = "Atlanta",
            State = "Georgia"
        }
    }, "ID")
    .Columns(columns => {
        columns.Add().DataField("CompanyName");
        columns.Add().DataField("City");
        columns.Add().DataField("State");
    })
)
@(Html.DevExtreme().DataGrid() _
    .ID("dataGrid") _
    .DataSource({
        New With { 
            .ID= 1,
            .CompanyName = "Super Mart of the West",
            .City = "Bentonville",
            .State = "Arkansas" 
        }, 
        New With {
            .ID = 2,
            .CompanyName = "Electronics Depot",
            .City = "Atlanta",
            .State = "Georgia"
        }
    }, "ID") _
    .Columns(Sub(columns)
        columns.Add().DataField("CompanyName")
        columns.Add().DataField("City")
        columns.Add().DataField("State")
    End Sub)
)
See Also

View Demo Watch Video

Configuration

This section describes the configuration options of the DataGrid widget.

Methods

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

Events

This section describes events fired by this widget.

See Also

Row

This section describes the properties of a grid row. An object containing these properties comes to certain event-handling functions.

Type:

Object