javascript中是否有任何标准函数可以使用包含以下数字的下拉列表控制表中每页显示的项目数:10,25,50等?
我尝试使用以下内容:
$(document).ready( function(){
$('#table').dataTable({
"iDisplayLength": 5,
"aLengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]]
});
});
但是它给了我2个错误
1)未捕获的TypeError:无法读取未定义的属性'asSorting' - data-tables-1.9.4.js:126
2)未捕获的TypeError:无法读取null的属性'parentNode' - data-tables-1.9.4.js:101
如果是,请告诉我。
提前致谢。
该表是通过jquery-ajax获取的
`function drawTable(){
$就({
url:GET_DATA_ACTION(),
dataType:“json”,
错误:function(errorStatus){
如果((errorStatus.status == 200)||(errorStatus.status> = 300)){
//pleaseWait.dialog("close“);
}
},
成功:函数(TABLE_DATA){
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"},
{"sTitle": TABLE_TITLE_COLUMN_NAME, "sType": "string", "sWidth": TABLE_TITLE_COLUMN_WIDTH,"mData": "programName"}
],
"aaSorting": [[4, "desc"]],
"aaData":TABLE_DATA,
"oLanguage": {
"sEmptyTable": TABLE_NO_DATA_MESSAGE,
"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(
$("<span></span>").attr({
"class": "ui-icon-search-object"
}).css({
"float": "left",
"position": "relative",
"top": "1px",
"left": "-5px"
})
).css({width: "auto"});
$("#loadingHome").hide();
}});
} 该表通过jquery-ajax
获取 function drawTable(){
$.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"}
],
"aaSorting": [[4, "desc"]],
"aaData":TABLE_DATA,
"oLanguage": {
"sEmptyTable": TABLE_NO_DATA_MESSAGE,
"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(
$("<span></span>").attr({
"class": "ui-icon-search-object"
}).css({
"float": "left",
"position": "relative",
"top": "1px",
"left": "-5px"
})).css({width: "auto"});
$("#loadingHome").hide();
}});
}