Datatable Custom Pagelength
Datatable Custom Pagelength
Has San
Posts: 5Questions: 1Answers: 0
I am using one datatable but i have a condition. i have variable named month i want to do if month is not equal to empty then i have to display my all records but if month is empty then the pageLength of datatable remains same as it is 10 and pagination remains same as well
This discussion has been closed.
Replies
You can use the
page.len()
API to set the length based on your condition. As described in the docs use-1
to show all the rows on one page.Kevin
thanks Kevin for you help but i try this when i use my if condition in my ajax it displays the syntax error which is saying JS ',' expected simple words i cant use if condition in my ajax
That is not the place for using the API. It would be used after Datatables is initialized. If the
month
variable is set before Datatables initialization you might be able to use thepageLength
option in the init settings. Something like this maybe:If this doesn't help then please provide more details of you you want this process to do.
Kevin
Here is my code where i getting the all records
function FilteredData(CustomerName) {
var customer = document.getElementById('CustomerName').value;
var customerNumber = document.getElementById('CustomerNumber').value;
var schedule = document.getElementById('Schedule').value;
var selectNumber = document.getElementById('selectNumber').value;
var selectSchedule = document.getElementById('selectSchedule').value;
var completed = document.getElementById('Completed').value;
var StartDate = document.getElementById('StartDate').value;
var completedornot = document.getElementById('CompletedorNot').value;
var month = document.getElementById('Month').value;
var Active = document.getElementById('Active').value;
As You can see the code when function calls we are getting values in variables in the **month **variable i need to handle
**if(month != "" || month != null || month != undefined{
pageLength Should be -1 or 100
}**
First you don't have the
,
at the end of the line to separate the options. So you are probably getting a syntax error.Maybe you need something more like this:
Kevin