-1

我开始为我的表使用数据表。我现在有一张桌子和顾客在一起。第一行是表头。第二行是添加新客户的按钮。其余行是客户列表。

我希望数据表对所有内容进行排序,而不是对“新客户”行进行排序。如何锁定该行/将其排除在排序之外?

试过这个:

<table class="muitable" border="0" cellpadding="0" cellspacing="3" id="customertable">
    <thead>
        <tr>
            <th>
            </th>
            <th>
            </th>
            <th class="muitable bluehover hand" >
                        Name
            </th>
            <th class="muitable bluehover hand" >
                        Created
            </th>
            <th class="muitable bluehover hand" >
                        Status
            </th>
        </tr>
        <tr>

            <th width="16">&nbsp;
            </th>
            <th class="muitable hovernextcell" onclick="newcustomer()">
                        <img src="/common/images/plus.png" width="16" height="16" class="hand">
            </th>
            <th class="muitable bluecell">
                        New customer
            </th>
            <th colspan="2">&nbsp;</th>
        </tr>   
    </thead>
    <tbody>
    --contents--
    </tbody>
</table>

现在出现的问题是“排序按钮”到处都是。当第二行的单元格中有值时,这成为按钮,如果没有,它使用第一行作为排序按钮。

如何告诉数据表单独留下第二行,只使用第一行作为标题?

4

2 回答 2

2

您可以将“添加客户”按钮放在标题中。像这样的东西:

 <thead>
        <tr>
            <th>Column 1</th>
            <th>Column 2</th>
            <th>etc</th>
        </tr>
        <tr>
            <th colspan="3">
                <button>Add Customer</button>
            </th>
        </tr>
    </thead>

现在 dataTables 不会对行进行排序。

jsFiddle:http: //jsfiddle.net/Fd3ED/

于 2013-07-17T20:30:17.880 回答
0

通过使用两个标题行并使用选项http://datatables.net/ref#bSortCellsTop来修复它

于 2013-07-19T08:39:40.343 回答