I am using php for loading data into datatable dynamically.I am displaying products categories group by in datatable. Each category row having 3 checkboxes accept/reject/cancel and below that, related category products will display with checkboxes.For example if user selected accept checkbox in category one then all the related accept checkboxes of the related products will check.Below is my php code.
For category chekboxes
$nestedData1[]=<input type=checkbox id=A_.$row['id'].' class='groupby_accept'>;
$nestedData1[]=<input type=checkbox id=R_.$row['id'].' class='groupby_reject'>;
$nestedData1[]=<input type=checkbox id=C_.$row['id'].' class='groupby_cancel'>;
$data[] = $nestedData1;
For products under category
$nesData[]= <input type=checkbox id=A_'.$row['id'].' class="A_'.$row['id'].' groupby_accept">
$nesData[]=<input type=checkbox id=R_'.$row['id'].' class="R_'.$row['id'].' groupby_reject">
$nesData[]= <input type=checkbox id=C_'.$row['id'].' class="C_'.$row['id'].' groupby_cancel">
$data[]=nesData;
//Draw datatable
$json_data = array(
"draw"=> intval( $requestData['draw'] ),// for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw.
"recordsTotal" => intval( $totalData ), // total number of records
"recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData
"data" => $data // total data array
);
echo json_encode($json_data);
Related jQuery
<script>
dataTable = jQuery('#lonp-data-grid').DataTable( {
"ajax":{
url :"<?php echo $site_url ?>lonp/loadlonpdata.php",//json datasource
type: "post"
}
});
</script>
Here i am getting row value as follow
jQuery('#lonp-data-grid tbody').on('click', 'tr', function () {
var data = dataTable.row( this ).data();
alert( 'You clicked on '+data[0]+'\'s row' );
} );
Here when i alert i am getting row value as
You clicked on table row
<input type=checkbox id=A_T1 class="A_T1 groupby_order_accept">'s row
But i need selected checkbox value, if user selects Accept checkbox then all related products accept checkboxes will check. How can i achieve this?Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire