2015-04-07 80 views
1

如何计算排序的列?
如果我点击列 “日期” 必须算出来的?1,接下来点击 “客户” 需要且具这2jQuery tablesorter,有编号的排序列

这是我的THEAD:

<thead> 
<tr> 
    <th>Quotation No</th> 
    <th>Date</th> 
    <th>Client</th> 
    <th>Manager</th> 
    <th>Total amount</th> 
    <th>Order</th> 
</tr> 
</thead> 

http://i58.tinypic.com/2lszc0n.jpg

+0

U-N-C-L-E-A-R,即使在编辑之后。 –

+0

你是什么意思?你遇到了什么问题,你有什么试验 – atmd

+0

例子http://i58.tinypic.com/2lszc0n.jpg –

回答

0

如果您正在使用我的fork of tablesorter,您可以使用下面的代码(demo):

$(function() { 
    $('table') 
     .on('sortEnd', function(){ 
      var i, 
       c = this.config, 
       list = c.sortList; 
      // clear indexes 
      c.$headers.find('.index').text(''); 
      for (i = 0; i < list.length; i++) { 
       c.$headers.eq(list[i][0]).find('.index').text(i+1); 
      } 
     }) 
     .tablesorter({ 
      theme: 'blue', 
      headerTemplate: '{content}{icon}<span class="index"></span>', 
      widgets: ['zebra'] 
     }); 
}); 

结果与示例截图中的结果不完全相同,但可以通过一些css修改来实现。

如果您使用的是原始tablesorter,则可以手动将<span class="index"></span>添加到每个标头。