Sorted icon appears even after setting ordering: false dynamically

Sorted icon appears even after setting ordering: false dynamically

rameshkanrameshkan Posts: 1Questions: 1Answers: 0
edited October 2021 in Free community support

I have a datatable which will load two different kind of data in a single table.

Example : Column headers are same in CASEA and CASEB. But for CASEA I do not provide sorting option and for CASEB sorting option is required.

Hence I have created the common column headers and define the dataTable as given below

  var table = $('#statment').DataTable();
    if(table)
        table.destroy();
    var type = $("#sttype").val();
    transTable = $('#statment').DataTable({
        paging: false,
        fixedHeader: true,
        ordering:   type == "CASEA" ? false : true,
        scrollY:"76vh"
        scrollCollapse: true,
        data: dataSet,
        "columnDefs": [
            { "width": "4%", "targets": 0 },
            { "width": "4%", "targets": 1 },
            { "width": "23%", "targets": 2 },
            { "width": "20%", "targets": 4 },
            {
                "targets": [13,14,15,16,17,18],
                "visible": false
            }],
        dom: 'Blfrtip',
    });

Step 1: It works fine in vanilla case, when the type is CASEA then I am not having the sorting option and column clicks or not working as expected.
Step 2: But when I select CASEB, sorting options are available. Hence I click on one column, say column 2, sorting works fine and the sorted icon appears. This is also working perfectly.
Step 3 : Now I am choosing CASEA again. Sorting behavior is not working as expected. But Column 2 still has the sorted icon visible.

Issue : Looks like it is an issue with the data table. Is there any way to hide the sorted icon?
Note: I am destroying the datatable every time when I load the data.

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.