Jquery 数据表按降序排序
我使用的是datatables 1.10,有一个相当大的表,需要大约一分钟才能加载。表通常在按降序排序时最有用,因此必须按(列)升序排序、等待,然后按(列)降序排序是相当烦人的。我知道有一种方法可以在默认情况下对列进行降序排序,但我在实现它时运气不佳。这是我的桌子:Jquery 数据表按降序排序,jquery,sorting,datatables,Jquery,Sorting,Datatables,我使用的是datatables 1.10,有一个相当大的表,需要大约一分钟才能加载。表通常在按降序排序时最有用,因此必须按(列)升序排序、等待,然后按(列)降序排序是相当烦人的。我知道有一种方法可以在默认情况下对列进行降序排序,但我在实现它时运气不佳。这是我的桌子: <div class="row"> <div class="col-xs-12"> <table id="reportTable" class="table table-cond
<div class="row">
<div class="col-xs-12">
<table id="reportTable" class="table table-condensed table-hover table-columntoggle display">
<thead>
<tr>
<th data-searchable="false" data-orderable="false" data-defaultcontent="" class="details-control"></th>
<th class="dt-left" data-data="ManufacturerPartNumber">Part Number</th>
<th class="dt-left" data-data="ItemName">Item Name</th>
<th class="dt-left" data-template="#templateWarehouseName">Warehouse</th>
<th class="dt-center" data-data="QuantityTimeBlock1" id="QuantityTimeBlock1Label">Quantity 0 to 45 Days</th>
<th class="dt-center" data-data="QuantityTimeBlock2" id="QuantityTimeBlock2Label">Quantity 46 to 90 Days</th>
<th class="dt-center" data-data="QuantityTimeBlock3" id="QuantityTimeBlock3Label">Quantity 91+ Days</th>
<th class="dt-center" data-data="TotalQuantity">Total Quantity</th>
<th class="dt-center" data-data="ValueTimeBlock1" id="ValueTimeBlock1Label">Value 0 to 45 Days</th>
<th class="dt-center" data-data="ValueTimeBlock2" id="ValueTimeBlock2Label">Value 46 to 90 Days</th>
<th class="dt-center" data-data="ValueTimeBlock3" id="ValueTimeBlock3Label">Value 91+ Days</th>
<th class="dt-center" data-data="TotalValue">Total Value</th>
<th class="dt-center" data-data="CurrencyType">Currency</th>
</tr>
</thead>
<tfoot>
<tr>
<th colspan="4" class = "dt-left">Page Totals:</th>
<th class = "dt-left">Total:</th>
<th class = "dt-left">Total:</th>
<th class = "dt-left">Total:</th>
<th class = "dt-left">Total:</th>
<th class = "dt-left">Total:</th>
<th class = "dt-left">Total:</th>
<th class = "dt-left">Total:</th>
<th class = "dt-left">Total:</th>
<th></th>
</tr>
</tfoot>
<tbody></tbody>
</table>
</div>
</div>
如果我取消注释,我会得到一个datatables错误“请求了第0行中的未知参数“x”。datatables文档说,这可能意味着我把事情搞砸了,或者我的行太多了。就我所知,HTML中的文本并不重要,因为它在页脚中。另一方面,如果我删除一行,页面将挂起,并且不会超出“加载”的范围
我怎样才能让它工作呢?好吧,我决定用这个不优雅但有效的解决方案来解决这个问题。因为这似乎不太可能在客户端很好地实现,所以我改变了控制器上的排序逻辑。而不是
case InventoryAgingValuationReportColumnType.ItemName:
query2 = orderBy.Item2 == OrderDirection.Ascendant ? query2.OrderBy(x => x.ItemName) : query2.OrderByDescending(x => x.ItemName);
break;
我现在有
case InventoryAgingValuationReportColumnType.ItemName:
query2 = orderBy.Item2 == OrderDirection.Ascendant ? query2.OrderByDescending(x => x.ItemName) : query2.OrderBy(x => x.ItemName);
break;
这不是最干净的方法,也不能真正解决我在数据表方面遇到的问题,但这是一种暂时可以接受的解决方法。什么是
abcdDataTable
?没有formSelector
或url
选项。列
数组中最后一项前面缺少逗号。abcdDataTable是我们在整个项目中使用的自定义数据表。缺少逗号是因为我在删除不必要的评论时太草率。
case InventoryAgingValuationReportColumnType.ItemName:
query2 = orderBy.Item2 == OrderDirection.Ascendant ? query2.OrderBy(x => x.ItemName) : query2.OrderByDescending(x => x.ItemName);
break;
case InventoryAgingValuationReportColumnType.ItemName:
query2 = orderBy.Item2 == OrderDirection.Ascendant ? query2.OrderByDescending(x => x.ItemName) : query2.OrderBy(x => x.ItemName);
break;