【问题标题】:Tablesorter plugin not sorting second TBodyTablesorter 插件未对第二个 TBody 进行排序
【发布时间】:2016-01-27 02:24:17
【问题描述】:

我根本无法让第二个 TBody 进行排序我做错了什么?第一个 tbody 工作正常,但第二个什么也不做。如果那行不通,我知道它应该这样做。然后我需要排序选项始终按类型排序,然后按用户选择的任何选项排序。有点像一组然后排序。

enter code here<table id="response-table" width="100%" cellpadding="1" cellspacing="1" class="tablesorter table">
                                <thead>
                                <tr style="border-bottom: thin solid black;">
                                    <th>Name</th>
                                    <th>Date modified</th>
                                    <th>Type</th>
                                    <th>Size</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach ( $folders as $folder)
                                    <tr class="document folder"  id="{{ $folder['id'] }}" style="border: none;">
                                        <td class="no-borders" width="60%"><i class="fa fa-folder text-warning"></i>&nbsp;{{ $folder['name'] }}</td>
                                        <td class="no-borders"><small>{{ date_format(date_create($folder['updated_at'])," m/d/Y  h:i a") }}</small></td>
                                        <td class="no-borders"><small>File folder</small></td>
                                        <td class="no-borders"></td>
                                    </tr>
                                @endforeach
                                </tbody>
                                <tbody>
                                @foreach ( $files as $file)
                                    <tr class="document file"  id="{{ $file['id'] }}" style="border: none;">
                                        <td class="no-borders" width="60%"><i class="fa fa-file text-primary"></i>&nbsp;{{ $file['name'] }}</td>
                                        <td class="no-borders"><small>{{ date_format(date_create($file['updated_at'])," m/d/Y  h:i a") }}</small></td>
                                        <td class="no-borders"><small>{{ $file['extension'] }}</small></td>
                                        <td class="no-borders">{{ $file['bytes'] }}</td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>

【问题讨论】:

    标签: jquery tablesorter


    【解决方案1】:

    如果您使用的是tablesorter.com的原始tablesorter(v2.0.5),它只支持第一个tbody(demo)的排序。

    要让 tablesorter 对多个 tbodies 进行排序,您需要切换到我的 fork of tablesorter - here is a demo

    $(function() {
    
      $("table").tablesorter({
        theme : 'blue',
        // class name added to tbodies where the content is ignored
        cssInfoBlock : "tablesorter-no-sort"
      });
    
    });
    

    【讨论】:

    • 谢谢!你能告诉我如何让排序箭头显示在表格标题中吗?
    • 选择并设置theme option,然后加载css。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-04
    • 1970-01-01
    • 1970-01-01
    • 2017-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多