1

我有一个基本的 html 页面,上面有一个 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
        });
    },
4

1 回答 1

1

查看fnRowCallback。您可以在回调期间确定要添加标题的行,然后在满足您的条件时注入新行。

于 2012-10-24T15:25:40.483 回答