我可以传递一个字符串,而不是像{'bSortable': false},null,null,null,null,null,null,null,null,null,null,null,null,null,{'bSortable': false}
in那样传递值,aoColumns
该字符串在数据表和 php 中也包含与上面相同的值吗?我的代码是这样的:
var excluded_clmns_sorting = $('#sorting_val').val();
//the above variable returns {'bSortable': false},null,null,null,null,null,null,null,null,null,null,null,null,null,{'bSortable': false}.
var oTable = $('#data-table').dataTable( {
"sDom": 'CT<"clear">firtlip',
"oTableTools": {
"sSwfPath": basePath+"/js/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
"aButtons": [ {"sExtends": "csv","sFileName" : curpath+".csv","sButtonText": "Save to CSV","mColumns": "visible"} ]
},
"aoColumns" : [excluded_clmns_sorting]
} );
在 js 控制台中显示nCell is undefined
. 请帮我。提前致谢。
//更新如果我在excluded_clmns_sorting
变量中传递数组并执行以下代码:
var excluded_clmns_sorting = $('#sorting_val').val();
var excluded_clmn_sorting = (excluded_clmns_sorting) ? excluded_clmns_sorting.split(",") : [];
$.each(excluded_clmn_sorting, function (i) {
excluded_clmn_sorting[i] = (excluded_clmn_sorting[i]);
})
var oTable = $('#data-table').dataTable( {
"sDom": 'CT<"clear">firtlip',
"oTableTools": {
"sSwfPath": basePath+"/js/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
"aButtons": [ {"sExtends": "csv","sFileName" : curpath+".csv","sButtonText": "Save to CSV","mColumns": "visible"} ]
},
"aoColumns" : [excluded_clmn_sorting],
"aoColumnDefs": [{
"bVisible": false,
"aTargets" : excluded_clmn
},
],
"iDisplayLength": 10,
'sPaginationType': 'full_numbers'
} );
然后在 js Console 中只显示oCol is undefined
.