2015-04-07 76 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>添加到每個標頭。