dropdown to control the number of items to be displayed per page
dropdown to control the number of items to be displayed per page
DimpleRohara
Posts: 3Questions: 0Answers: 0
I want a dropdown to control the number of items to be displayed per page in a datatable. I tried using
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]] but its not working for me.
I am using ajax-jquery code to fetch the record in the datatable.
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]] but its not working for me.
I am using ajax-jquery code to fetch the record in the datatable.
This discussion has been closed.
Replies
$.ajax({
url: GET_DATA_ACTION(),
dataType: "json",
error:function(errorStatus) {
if((errorStatus.status==200)||(errorStatus.status>=300)){
//pleaseWait.dialog("close");
}
},
success: function(TABLE_DATA) {
// table configuration
var table = $("#content_objects_table").dataTable({
"bJQueryUI": true,
"bDeferRender": true,
"bDestroy" : true,
"sScrollY": TABLE_SCROLL_HEIGHT + "px",
"bScrollCollapse": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"oSearch": {"sSearch": "", "bSmart": true},
"bSortClasses": false,
"aoColumns": [
{"sTitle": TABLE_ID_COLUMN_NAME, "sType": "string", "bSearchable": false,"bVisible": false,"mData": "id"}, // id column
{"sTitle": TABLE_TITLE_COLUMN_NAME, "sType": "string", "sWidth": TABLE_TITLE_COLUMN_WIDTH,"mData": "programName"} // name column
],
"aaSorting": [[2, "desc"]],
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"aaData":TABLE_DATA,
"oLanguage": {
"sEmptyTable": TABLE_NO_DATA_MESSAGE,
"sLengthMenu": "Display _MENU_ records per page",
"sSearch": ""
},
"fnDrawCallback": function () {
drawContextMenu();
$("#content_objects_table_length").hide();
//$("#content_objects_table_length").find("label").css({"color":"white"});
}
});
$("#content_objects_table_wrapper").css("min-height", "0px");
$("#content_objects_table_filter").prepend(
$("").attr({
"class": "ui-icon-search-object"
}).css({
"float": "left",
"position": "relative",
"top": "1px",
"left": "-5px"
})
).css({width: "auto"});
$("#loadingHome").hide();
}});
}
The code above looks like it should work to me.
Allan