How to high light sorted dynamically column

How to high light sorted dynamically column

arvindg82arvindg82 Posts: 21Questions: 4Answers: 0

How to high light column on which basis data table is sorted and Column is dynamically every time (column name not fixed)?

Replies

  • kthorngrenkthorngren Posts: 21,800Questions: 26Answers: 5,043

    This example shows the CSS selector needed to highlight sorted columns. See the CSS tab.
    https://live.datatables.net/nehehuku/1/edit

    Column is dynamically every time (column name not fixed)?

    Not sure what you mean by this. If the above doesn't help then please provide a simple test case showing the dynamic column so we can offer suggestions.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • arvindg82arvindg82 Posts: 21Questions: 4Answers: 0

    Column name change every time but how to active column name on which it seems to be sorted.

  • kthorngrenkthorngren Posts: 21,800Questions: 26Answers: 5,043
    edited March 15

    The example I linked to above doesn't rely on the column name. The sorted column can change and the CSS will apply the appropriate highlight styling.

    Its possible that I don't understand what you are trying to achieve. Again if you need help with this then please provide a simple test case that shows what you have so we can offer more specific suggestions.

    Kevin

  • kthorngrenkthorngren Posts: 21,800Questions: 26Answers: 5,043

    Maybe you are asking about highlighting a column. See this example:
    https://live.datatables.net/loheyupe/85/edit

    The example shows highlighting all the cells in a row, highlighting all the cells in a column and highlighting the tr.

    Kevin

  • burbur Posts: 25Questions: 2Answers: 0
    edited March 15

    In this test case (building on kthorngren's), the ordered column is highlighted each time the table is ordered:
    https://live.datatables.net/loheyupe/86/edit

    I don't know why the draw event doesn't fire on init here, in my own script it does.

    Edit: actually it's running one ordering behind, I guess the sorting_1 class is only added after the draw (which makes sense now that I think about it).
    Edit2: Ok now it works, except still on init.

  • kthorngrenkthorngren Posts: 21,800Questions: 26Answers: 5,043
    edited March 15

    @bur use the order event and initialize it before initializing Datatables. Like this:
    https://live.datatables.net/fakoteqe/1/edit

    Code might need to be added for the case of the third click removing ordering on the column.

    Kevin

Sign In or Register to comment.