How To Add RowId and RowClass on Datatable

Previous post we have learn how to use DataTables Example with PHP,in this article we will learn how to add rowid and rowclass with each row into data table.Some times we need to identify each row based on id or row class.Jquery datatable has many properties for easy handle datatable with server side.

Also Checkout other tutorial of Datatable,

The following are three properties which is used to identify unique each row.

  • {string} DT_RowId – Add an ID to the TR element.
  • {string} DT_RowClass – Add a class name to the TR element.
  • {object} DT_RowData – Add HTML5 data- attributes to the TR element. This is an object of key / value pairs which are assigned as data attributes to the TR element.


How To Add RowId on Each Row in Datatable :

We will add id on each row of table using below syntax.

with help of above code, you can see ‘6’ id has been attached against with ‘parvez’ row data like below,