1

我可以传递一个字符串,而不是像{'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.

4

1 回答 1

0

你可以放一个arrayaoCoumnsstring

aoColumns: 如果指定,则 this 的长度array必须等于columns原始 HTML 表格中的数量。如果您希望仅使用默认值和自动检测的选项,请使用“null”。

在这里阅读

希望对你有帮助

于 2013-07-31T10:17:03.250 回答