The export button does don't appear after filter data
The export button does don't appear after filter data
Al-Amin Msangi
Posts: 5Questions: 1Answers: 0
Good day team.
I use the yajra datatable server side to display data to the table and export it. When I load data for the first time the export buttons appear but when I filter the data by the date the export buttons disappear. Please, anyone can help with this.
loadCustomer()
var startDate;
var endDate;
var table;
$(document).ready(function(){
$('#filter').click(function(){
var status = $('#status').val();
table.destroy();
loadCustomer(startDate,endDate,status);
})
$('#refresh').click(function(){
startDate = ''
endDate = ''
status = ''
table.clear().draw();
})
})
function loadCustomer(start_date = '', end_date = '', status = ''){
table = $('#customer_table').DataTable({
dom: 'Bfrtip',
buttons: ['csv','print', 'excel', 'pdf'],
processing:true,
serverSide:true,
ajax:{
url:'{{ url('report/customer/list') }}',
data:{start_date,end_date,status}
},
columns:[
{
data:'DT_RowIndex',
name:'DT_RowIndex'
},
{
data:'applicant_name',
name:'applicant_name'
},
{
data:'applicant_phone',
name:'applicant_phone'
},
{
data:'applicant_address',
name:'applicant_address'
},
{
data:'street_name',
name:'street_name'
},
{
data:'user_code',
name:'user_code'
},
{
data:'status',
name:'status'
},
{
data:'meter_number',
name:'meter_number'
},
{
data:'account_type_name',
name:'account_type_name'
},
{
data:'area',
name:'area'
},
{
data:'plot_number',
name:'plot_number'
},
{
data:'house_number',
name:'house_number'
},
{
data:'owner_name',
name:'owner_name'
},
{
data:'owner_phone',
name:'owner_phone'
},
{
data:'water_closet',
name:'water_closet'
},
{
data:'unrinals',
name:'unrinals'
},
{
data:'baths',
name:'baths'
},
{
data:'stand_pipes',
name:'stand_pipes'
},
{
data:'others',
name:'others'
},
{
data:'created_at',
name:'created_at'
}
]
})
}
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
This discussion has been closed.
Answers
When you filter is this function executed?
Looks like it should work. It destroys the Datatable and reinitializes it. I would start by looking at the browser's console for errors.
Kevin
Yeah is the function that is called.
But there is no error in my web console.
Can you post a link to your page or a test case replicating the issue? This way we can take a look at what is happening to offer suggestions.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Can we use TeamViewer or live share with visual code?
Or we can start from here, Skype: alaminhamadi.
Please help me because it takes me 3 days until today.
After using Datatables Debugger, when I filter the data on datatable information return "Information about 0 tables available"
The Datatables developers may help this way but I believe they might charge for the service. You can contact @allan or @colin to find out the details.
I assume the debugger works correctly before you filter?
That suggests that after the
destroy()
theloadCustomer
function is not working correctly. Using the browser's developer tools do you see an Ajax request being sent when you filter?Use some
console.log
statements to help debug the path of your code. I would start with one in theloadCustomer
function to make sure its called when you try filtering.Kevin
I have check as you suggested above and the loadCustomer function is called.
Please let me show a hole script.
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin