Custom Setting Length Menu
Custom Setting Length Menu
I have a DataTable that's doing server side processing. I'm returning the total number of records to the grid, and want to use that to dynamically set the LengthMenu. I can calculate the array in the drawCallback property, but the LengthMenu property ignores that.
So, in this initialization:
var pageSizeBuilder = [25, 50, 75];
var table = $('#' + tableName).DataTable({
"autoWidth": false,
"processing": false,
"serverSide": true,
"stateSave": true,
"renderer": "bootstrap",
"ajax": {
"url": "/" + TableOptions.Controller + "/" + Action + "/",
"data": function (d) {
d.includeDeleted = $('#chkFilterDeleted').is(':checked')
if(TableOptions.Controller == "FacilityResourceData")
{
d.ssc = $('#States option:selected').val(),
d.ft = $('#FacilityTypes option:selected').text()
}
},
"type": "POST",
"datatype": "json"
},
drawCallback: function (d) {
pageSizeBuilder = [25, 50]
},
"columns": ColumnDefinitions,
aLengthMenu: pageSizeBuilder
});
the Page Length options are 25, 50 and 75, which is what I specified when the pageSizeBuilder array was initialized, not what was assigned in the drawCallback. How can I dynamically set up the options in the page length menu?