How to Export Checked Row (I m using checkbox to select rows)?
How to Export Checked Row (I m using checkbox to select rows)?
Sanit Kale
Posts: 23Questions: 9Answers: 0
1.Server side code
while( $row=mysqli_fetch_array($queryRecords) )
{
$nestedData=array();
$nestedData[] = "<input type='checkbox' onclick='checkboxfn($(this));' id='singleBox' value='". $index."' />" ;
$nestedData[] = "<i class='mdi mdi-format-list-bulleted'></i>";
$nestedData[] = $index;
$nestedData[] = $row["Designation"];
$nestedData[] = $row["CompanyName"];
$nestedData[] = $row["PersonalEmail"];
$nestedData[] = $row["PersonalPhone"];
$nestedData[] = $row["PersonalMobile"];
$data[] = $nestedData;
$index++;
}
$json_data = array(
"draw" => 1,
"recordsTotal" => intval( $totalRecords ),
"recordsFiltered" => intval($totalRecords),
"data" => $data // total data array
);
echo json_encode($json_data); // send data as json format
- My Button Code
dom: 'lBfrtip',
buttons: [
{
extend: 'copyHtml5',
exportOptions: {
columns: [6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 ]
}
},
{
extend: 'excelHtml5',
text: 'XLS',
exportOptions: {
columns: [6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]
}
},
{
extend: 'csvHtml5',
exportOptions:
{
columns: [6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]
}
},
{
extend: 'pdfHtml5',
orientation: 'landscape',//landscape give you more space
pageSize: 'A0',//A0 is the largest A5 smallest(A0,A1,A2,A3,legal,A4,A5,letter))
exportOptions: {
columns: [7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]
}
},
],
columnDefs: [{
"targets": 5,
"orderable": true
}]
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi Sanit,
This example may be useful - it explains about exporting selected rows.
Hope that helps,
Cheers,
Colin
Thank You, Sir, For Your Response Its Very kind of you.
But My Problem Is I am Trying to Select Rows Using Custome Checkboxes and I am Pushing respected Row's ID to Export
I am getting " Uncaught TypeError: Cannot read property '0' of null" this Error
Actually, My Excel Export Is working Fine but CSV and Copy Is not working
This is my Excel Export Code.
This Is My Copy and CSV Code
my rowID Pushing Code
As you pointed out that this line is giving an error
rowIds.indexOf(l[i].match(/\d+/)[0])
I would suggest debugging around
l[i].match(/\d+/)
- I suspect that's returningnull
, which you're then accessing with[0]
Thanks, Sir, Now Its working Perfectly Fine