2012-05-24 74 views
1

我有一个基本的HTML页面,其上有一个jQuery DataTables网格。 我能够如何将自定义行添加到jQuery DataTables插件

http://datatables.net/index

它显示在浏览器就好了。问题是我想为每个部分添加自定义行标题。所以行标题可以位于第3行,第8行......等等。我如何在数据表的中间动态插入行标题?

getDataOverview: function ($page) { 
     $page.find('#tblDataTable').dataTable({ 
      "bServerSide": true, 
      "fnDrawCallback": onAfterTableLoad, 
      "bJQueryUI": false, 
      "bFilter": false, 
      "bPaginate": false, 
      "bLengthChange": false, 
      "oLanguage": { "sInfo": "" }, 
      "sAjaxSource": this.getUrl($page) + '/GetDataOverview/', 
      "fnServerData": function (sSource, aoData, fnCallback) { 

       $.ajax({ 
        dataType: 'json', 
        type: "POST", 
        url: sSource, 
        data: aoData, 
        success: fnCallback, 
        error: function (jqXHR, textStatus, errorThrown) { alert('Error getting data' + errorThrown) } 
       }) 
      }, 
      "bProcessing": false, // don't want to use the default progress indicator at this time 
      "aoColumnDefs": [ 
       { "sName": "ID", "aTargets": [0], "mDataProp": "ID", "bSortable": false }, 
       { "sName": "Name", "aTargets": [1], "mDataProp": "Name", "bSortable": false }, 
       { "sName": "Other", "aTargets": [2], "mDataProp": "Other", "bSortable": false } 
      ], 
      "aaSorting": [[0, "asc"]] // default sort by Task Type 
     }); 
    }, 

回答

1

结账fnRowCallback。您可以在回调期间确定要添加标题的行,然后在符合条件时注入新行。

相关问题