jQuery表头排序

时间:2008-10-14 18:23:39

标签: jquery sorting

有人知道插件或内置函数使表中的列可以排序吗?即我点击列标题并按该列对行进行排序?

6 个答案:

答案 0 :(得分:27)

http://tablesorter.com/docs/非常易于使用,提供多种选项以满足您的需求。 :)

答案 1 :(得分:3)

http://www.flexigrid.info/

Flexigrid是一款非常流行且易于使用的表管理器/分类器。

答案 2 :(得分:2)

这里有两个可以排序并执行许多其他我尚未看到列出的内容:

这里还有一个比较许多数据表的表:http://blog.sematext.com/2011/09/19/top-javascript-dynamic-table-libraries/

答案 3 :(得分:1)

有点重量级,但最终的jQuery表管理器是jqGrid

答案 4 :(得分: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

答案 5 :(得分:-1)

Ext JavaScript library非常擅长。

相关问题