Add sorting to DataGrid

Tutorial » Add sorting to DataGrid

This example demostrates how to sort the DataGrid by clicking on header of a column.

All columns in DataGrid can be sorted by clicking on header of column. You can define which column can be sorted. By default the column cannot be sorted unless you set the sortable property to true.

Create DataGrid

We defines some sortable columns including itemid,productid,listprice,unitcost etc. The 'attr1' column and 'status' column cannot be sorted.

When sorting the DataGrid will send two parameters to server:

  • sort: The sort column field name.
  • order: The sort order, can be 'asc' or 'desc', default is 'asc'.

The Server Code

Download the EasyUI example:

easyui-datagrid-demo.zip