datatables. code example

Example 1: add checkbox in server side datatable laravel

->editColumn('select_orders', static function ($row) {
                return '<input type="checkbox" name="registrations[]"
                value="'.$row->id.'"/>';
            })->rawColumns(['select_orders'])
  
  Inside Config/datatables.php 
 'raw'       => ['action', 'checkbox'],

Example 2: C# create DataTable

DataTable dt = new DataTable(); 
dt.Clear();
dt.Columns.Add("Name");
dt.Columns.Add("Marks");

DataRow _ravi = dt.NewRow();
_ravi["Name"] = "ravi";
_ravi["Marks"] = "500";
dt.Rows.Add(_ravi);

Example 3: datatable

<link href="//cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css">
<script src="//cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>

<table id="Table_ID">
  <thead>
    <tr>
        <th>Table_Head_1</th>
        <th>Table_Head_2</th>
        <th>Table_Head_3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
    	<td>Table_Data_1</td>
      	<td>Table_Data_2</td>
      	<td>Table_Data_3</td>
    </tr>
  </tbody>
</table>

<script>
$(document).ready( function () {
    $('#Table_ID').DataTable();
} );
</script>

Example 4: datatables

Javascript123$(document).ready( function () {    $('#myTable').DataTable();} );

Example 5: datatable

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.22/datatables.min.css"/>
 
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.22/datatables.min.js"></script>

Example 6: how to make a datatable in c#

Datatable NameHere = new DataTable();
NameHere.Rows.Add("Whateveryoudliketoaddintorstringoranything");