Most of the time you face hard time to render data into datatables and much more harder thing is to use ajax. In this package I have made it so easy that with 4 arguments you can build your datagrid and use it in a very efficient way . the theme that this datagrid is build on is metronic ver.4.
With composer :
{
"require": {
"mkdesignn/datagridview": "1.4"
}
}
mkdesignn\datagridview\MkDatagridviewServiceProvider::class
"DataGrid" => mkdesignn\datagridview\DataGrid::class
$table:: 'Table_name'
$columns:: ['column_1', 'column_2'];
$columns_title:: ['column_1_name', 'column_2_name'];
$data_table_id:: 'table_1'
echo DataGrid::build($table, $columns, $column_title, $data_table_id)->render();
the above code will give you full dynamic datatable .
What if you wanted to retrieve only the result and you did not interest with the view of the table, the only things you should do it's to use result instead of render
$table:: 'Table_name'
$columns:: ['column_1', 'column_2'];
$columns_title:: ['column_1_name', 'column_2_name'];
$data_table_id:: 'table_1'
DataGrid::build($table, $columns, $column_title, $data_table_id)->result();
the above code will return you result which you can access it by ajax.complete method which this result is derived of you'r data_table_id.
$.ajaxComplete(function(event, xhr, data){
console.log(data_table_id) // will show you the result
})
the result its an object which contains records, column per page, current_page, and much more ...
what if you want to use filtering on your datatable, well its very easy in using this datagrid.
$table:: 'Table_name'
$columns:: ['column_1', 'column_2'];
$columns_title:: ['column_1_name', 'column_2_name'];
$data_table_id:: 'table_1'
$type = ['column_to_use_it_as_filter']
DataGrid::build($table, $columns, $column_title, $data_table_id, $type)->result();
and thats it , now you can use it with one filter on your datatable. which you can filter throught it and also search by choosin that one single filtering .