2008-10-14 77 views

回答

27

http://tablesorter.com/docs/是非常簡單的使用範圍廣泛的選項,以滿足您的需求。 :)

+3

的tablesorter是真棒 – 2008-10-15 00:19:52

1

有點重量級的,但最終的jQuery表管理器是jqGrid

0

jquery插件,使排序,篩選和分頁:breedjs

例子:

放在一個JS對象中的數據做就像這樣:

var data = { 
    people: [ 
     {name: 'a', address: 'c', salesperson: 'b'}, 
     {name: 'b', address: 'b', salesperson: 'a'}, 
     {name: 'c', address: 'a', salesperson: 'c'}, 
    ] 
}; 

breed.run({ 
    scope: 'people', 
    input: data 
}); 

HTML:

<table> 
    <thead> 
     <tr> 
      <th sort='name'>Name</th> 
      <th sort='address'>Address</th> 
      <th sort='salesperson'>Sales Person</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr b-scope="people" b-loop="person in people"> 
      <td b-sort="name">{{person.name}}</td> 
      <td b-sort="address">{{person.address}}</td> 
      <td b-sort="salesperson">{{person.salesperson}}</td> 
     </tr> 
    </tbody> 
</table> 

現在,每當你想通過銷售人員進行排序,只叫它:

breed.sort({ 
    scope: 'people', 
    selector: //field name 
}); 

請參閱:

$("th").click(function(){ 
    breed.sort({ 
     scope: 'people', 
     selector: $(this).attr('sort') 
    }); 
}); 

Working example on fiddle