Categories: Jquery

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.

Related Post
  • {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.

array("DT_RowId"=> "6",'Name'=>'parvez', 'Empid'=>11, 'Salary'=>101)

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

<tr id="6"><td>Parvez<td> ...</tr>

View Comments

    • Hi Nadeem,
      You need to create your rows data as like array("DT_RowId"=> "6",'Name'=>'parvez', 'Empid'=>11, 'Salary'=>101),as per my understanding u do not have DT_RowId col in ur reponse, so u need to add DT_RowId col in php response.

Recent Posts

Configure and Retrieve S3 Information Using Laravel PHP-AWS-SDK

This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More

3 months ago

What is the Purpose of php_eol in PHP?

in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More

9 months ago

Laravel Table Relationship Methods With Example

This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More

9 months ago

Exploring the Power of Laravel Eloquent Join?

We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More

9 months ago

Quick and Easy Installation of Laravel Valet

in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More

10 months ago

What is Laravel Soft Delete and How Does it Work?

I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More

10 months ago

Categories