How to remove sorting option from DataTables?

2020-06-01 05:21发布

I'm using DataTables plugin. I don't want to use the sorting option (to sort the columns in ASC or DESC order) which comes by default on each <thead>. How can I remove that sorting icon?

8条回答
再贱就再见
2楼-- · 2020-06-01 05:58

You can e.g. set style="display:none;" to the arrow element. You can set it programmatically using JavaScript or you can use CSS class. Firstly you have to examine the HTML code (the arrow element) using some developer console like FireBug.

查看更多
Lonely孤独者°
3楼-- · 2020-06-01 06:03

You can set it by bSortable to false in aocolumn like :

$('#example').dataTable({
 "aoColumns": [
                                 { "sType": "html","bSortable": false, "bSearchable": false },
                                 { "sType": "html" },
                                 { "sType": "html", "bSortable": false, "bSearchable": false },
                                 { "sType": "html" },
                                 { "sType": "html","bSortable": false, "bSearchable": false },
                                 { "sType": "html" },
                                 { "sType": "html" },
                                 { "sType": "html" },
                                 { "sType": "date-euro" }
                                 ]

                            });

You can also exclude from search by set bSearchable to false

查看更多
登录 后发表回答