0

我正在使用 Jquery DataTable,我在这里面临两个主要问题。如果我使我的一个列不可见,而不是排序会滑倒,我的意思是如果要对列进行排序,我必须先单击该列。我的第二个问题是如何在我可以使用的类的情况下将 css id 添加到给定列sClass:"myclassname"。我的代码如下所示

//===== Dynamic data table =====//

oTable = $('.dTable').dataTable({
        "bJQueryUI": false,
        "bAutoWidth": false,
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": 'data.php',
        "aoColumns": [
                      null, // the first column is invisible
                      { "bVisible": false },
                      null,
                      null,
                      null,
                      null,
                      null,
                      null,
                      null,
                      null,
                      null,
                      null,
                      null,
                      null,
                      { "bSortable": false },
                      { "bSortable": false, "sClass": "mEdit"  },
                      { "bSortable": false }                  
         ],

    "sPaginationType": "full_numbers",
    "oLanguage": {
        "sLengthMenu": "<span class='showentries'>Show entries:</span> _MENU_"
    }
});
4

1 回答 1

0

你的意思是'将css id添加到列中的每个单元格'?如果是这样:

var colIndex = 4;

$('.dTable').children('tr').each(function(){
  $(this).children('td').eq(colIndex).css('myclassname');
});

至于排序,您可以设置iDataSort每列的属性以显式指定要排序数据的列(请参见此处: http: //www.codeproject.com/Articles/194916/Enhancing-HTML-tables-using- a-JQuery-DataTables-pl#Sorting )

于 2013-02-22T10:08:33.943 回答