using datatable api order(0, "asc").draw() show sort icon

using datatable api order(0, "asc").draw() show sort icon

yu yen kanyu yen kan Posts: 65Questions: 31Answers: 0

I am setting the column with orderable false and class no-sort, but when I execute datatable api for ordering, the sorting icon is appear and the header become strange

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We would really need to see your issue to be able to understand/debug the issue. It's working as expected in this example. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Colin

  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948

    order(0, "asc").draw()

    This is the wrong syntax for the order() API. The API expects an array with the column and direction. See the docs for details. You will want something more like this:

    table.order( [0, "asc"] ).draw();
    

    Kevin

  • yu yen kanyu yen kan Posts: 65Questions: 31Answers: 0

    https://live.datatables.net/famefego/1/edit

    check the example, even I disabled ordering on the table column name and position, when I order with name programmatically, the sorting icon is still showing, so I cant make my own sorting icon..

  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948
    edited September 2023

    Setting columns.orderable to false only turns off ordering of the column by the end user. The sorting icons will show if the table is ordered by that column. By default Datatables orders the table by column 0. You can use order to change the default order to a different column or not initially order the table with order: [], like this:
    https://live.datatables.net/sobujufa/1/edit

    Are you wanting to sort by column 0 but not show the sorting icon?

    Kevin

  • yu yen kanyu yen kan Posts: 65Questions: 31Answers: 0

    https://datatables.net/forums/discussion/77254/rowspan-on-table#latest
    this is what I am trying to do, I want to make sorting for both top and bottom header when using rowspan, so I am trying to hide existing sort icon and do my own sort icon with datatable ordering feature.

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    As I noted in your other thread, rowspan is not possible in DataTable's tbody at this time. Sorry.

    Allan

Sign In or Register to comment.