Jquery 是否允许DESC/ASC对表列进行排序?

Jquery 是否允许DESC/ASC对表列进行排序?,jquery,twig,Jquery,Twig,我正试图找出一种方法,让员工能够对表格进行排序。我想我会创建一个带有选项的选择框,一旦单击了一个选项(即文件名),表就会按文件名降序排列。我正在使用Twig作为我的模板语言,但找不到一种方法来使用它。我能做这件事的最好方法是什么 <script type="text/javascript"> $(document).ready(function(){ $('.remove').on('click', function(event){ $.post('php

我正试图找出一种方法,让员工能够对表格进行排序。我想我会创建一个带有选项的选择框,一旦单击了一个选项(即文件名),表就会按文件名降序排列。我正在使用Twig作为我的模板语言,但找不到一种方法来使用它。我能做这件事的最好方法是什么

<script type="text/javascript">
$(document).ready(function(){

    $('.remove').on('click', function(event){

        $.post('phplib/remove_forward.php', {
                'id' : $(this).data('id')
            },function(data){
                if(data === 'true'){
                    $(event.target).parent().parent().remove();
                }
                console.log(data);
            },'html');
        event.preventDefault();
    });
});
</script>
<div id='content'>
    <h1>Signoffs</h1>
    <p>Sort by:<select id='sortby'><option></option><option>Filename</option></select></p>
    <table class='fancy'>
        <thead>
            <tr>
                <th>Filename</th>
                <th>Another name</th>
                <th>Machine</th>
                <th>Operator</th>
                <th>Leader</th>
                <th>Date</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            {% for item in signoffs %}
            <tr>
                <th><a href='http://files.example.com/folder/{{ item.job_folder }}/department/Files/{{ item.dep.file_name }}'>{{ item.dep.file_name }}</a></th>
                <td><a href='view.php?num={{ item.num }}&amp;file_id={{ item.dep.id }}'>Lineup</a></td>
                <td>{{ item.machine.name }}</td>
                <td>{{ item.operator.user.name }}</td>
                <td>{{ item.leader.user.name }}</td>
                <td>{{ item.date|date('M d, Y') }}</td>
                <td><a class='remove' data-id='{{ item.id }}' href=''>remove</a></td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

$(文档).ready(函数(){
$('.remove')。在('click',函数(事件){
$.post('phplib/remove_forward.php'{
'id':$(this.data('id'))
},函数(数据){
如果(数据=='true'){
$(event.target).parent().parent().remove();
}
控制台日志(数据);
},'html');
event.preventDefault();
});
});
签字
排序方式:文件名

文件名 另一个名字 机器 操作人员 领导 日期 {签核%中项目的%s} {{item.machine.name} {{item.operator.user.name} {{item.leader.user.name} {{item.date}date('md,Y')} {%endfor%}
您应该检查一下它是一个非常棒的jquery插件,它允许表操作

它的使用非常简单,非常推荐