what do you mean by disable pagination?
do you mean hide the pagination controls?
Yes,to hide pagination controls if there only one page returned.
are you using local or remote pagination?
remote pagination
In that case i would suggest you use the ajaxResponse callback, to check the number of pages available and hide/show the footer as needed:
$("#example-table").tabulator({
ajaxResponse:function(url, params, response){
//url - the URL of the request
//params - the parameters passed with the request
//response - the JSON object returned in the body of the response.
if(response.last_page == 1){
$(".tabulator-footer").hide();
}else{
$(".tabulator-footer").show();
}
return response; //return the response data to tabulator
},
});
hey oli,
could i use ajaxResponse call back and setData function together?
i tried using and ended up with errors
$("#device-table").tabulator("setData",{
url:window.location.protocol+ "//" + window.location.host + "/users/getDevice",
params:{key1:value},
ajaxResponse:function(url, params, response){
//url - the URL of the request
//params - the parameters passed with the request
//response - the JSON object returned in the body of the response.
if(response.last_page == 1){
$(".tabulator-footer").hide();
}else{
$(".tabulator-footer").show();
}
return response; //return the response data to tabulator
},
});
thank you!
Hey,
they ajaxResponse callback has to be defined in your tabulator constructor, you cannot pass it to the setData function.
Cheers
Oli
hi oli,
works well!
how do i do the same thing for local pagination?
thank you!
For local pagination you could do something similar on the dataLoaded callback:
$("#example-table").tabulator({
dataLoaded:function(data){
//data - all data loaded into the table
if($("#example-table").tabulator("getPageMax")){
$(".tabulator-footer").hide();
}else{
$(".tabulator-footer").show();
}
},
});
Actually having thought about it, this approach should work for both local and remote pagination
Cheers
Oli
yaay!! thanks again!
hey oli,
is there a way to hide pagination if after filtering only one page is returned?
with remote or local pagination?
remote pagination
are you filtering remotely as well or filtering localy in the table?
i am filtering remotely
if you are filtering remotely then your server should be updating the last_page value in the response to match the number of pages available to match your filtered response. In which case the previous code snippets should work for you
it works good now!
thabnk you!