3

在删除数据表标题行上的排序箭头(asc 和 desc)时需要帮助,然后当用户单击标题列时,将出现一个升序箭头,当然数据将按 asc 顺序排序

4

6 回答 6

4
 $("#MyDataTable").dataTable({            
 "aoColumns": [{"bSortable": false}, null]        
 }); 
于 2012-07-02T17:55:33.543 回答
4
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 1, 3 ] } ]

从第二列和第四列中删除排序箭头。

参考:http ://wordpress.org/support/topic/plugin-wp-table-reloaded-removing-the-updown-sorting-arrows-on-specific-columns

于 2012-11-20T05:41:42.040 回答
3
> This is Best Answer for removing sort arrow
> 
> 
> $('#itjbg-table').dataTable({
>     'columnDefs': [{ 'orderable': false, 'targets': 0 }], // hide sort icon on header of first column
>     'aaSorting': [[1, 'asc']] // start to sort data in second column });
于 2017-01-08T11:03:33.160 回答
1

在 dataTables.Bootstrap.css 中有三个添加这些排序图像的类。它们是sorting、sorting_asc 和sorting_desc。在 DataTable 初始化期间,禁用排序,如“satej kumar sahu”通过 bSortable 所述:false。然后为标题做一个removeClass,我的标题有一个id="division"。然后为标题创建一个单击事件,相同的 id,执行另一个 removeClass 以保留任何其他功能,在我的情况下,通过 columnFilter 保留列下拉列表。查看附加代码。

$('#example').dataTable({
            "order": [[1, "asc"], [7, "asc"], [4, "asc"]],
            "aoColumnDefs": [{ "bSortable": false, "aTargets": [1]}],
            "columns":[null, {className: ""}, null, null, null , null, null, null, null, null]
        }).columnFilter({
            sPlaceHolder: "head:after",
            aoColumns: [null, { type: "select" }, null,
            null, null, null, null, null, null, null]
        });
        $('#division').removeClass('sorting sorting_asc sorting_desc');


$('#division').click(function () {
        		    $('#division').removeClass('sorting sorting_asc sorting_desc');
        		});
table.dataTable thead .sorting { background: url('../images/sort_both.png') no-repeat center right; }
table.dataTable thead .sorting_asc { background: url('../images/sort_asc.png') no-repeat center right; }
table.dataTable thead .sorting_desc { background: url('../images/sort_desc.png') no-repeat center right; }
<thead>
                    <tr class="info">                                     
					    <th scope="col">Title</th>
					    <th id="division" scope="col">Division</th>                        
                        <th scope="col">Attendee</th>
                        <th scope="col">Supervisor</th>
					    <th scope="col">Start Date</th>
					    <th scope="col">End Date</th>
                        <th scope="col">Duration(hr)</th>
					    <th scope="col">Fee</th>
                        <th scope="col">Status</th>
                        <th scope="col">Comments</th>					   
                    </tr>    
                </thead>

于 2015-01-22T19:42:24.950 回答
1

如何删除数据表 GLYPHCONS / 图标!


在您的 css 文件上使用以下代码:如果您在表头上看到列 glyph-cons,请使用此!

th.sorting_asc::after, th.sorting_desc::after { 内容:"" !important; }

如果您看到表格数据上的字形标志,请使用它!

td.sorting_asc::after, td.sorting_desc::after { content:"" !important; }

简而言之,更改class="sorting_desc/asc"所在的“this”部分。

"this".sorting_asc::after, "this" .sorting_desc::after { content:"" !important; }
于 2018-01-13T08:52:39.757 回答
0

我从您的问题中得到的是,您想从表中删除初始排序,并且仅在用户单击列标题时进行排序。您可以使用以下代码执行此操作:

$(document).ready( function() {
  $('#example').dataTable( {
    "aaSorting": []
  } );
} );

http://datatables.net/ref#aaSorting

于 2013-10-21T17:50:39.013 回答