After destroying and reinitiating the datatable , the selection and deselection not working

After destroying and reinitiating the datatable , the selection and deselection not working

polachanpolachan Posts: 101Questions: 50Answers: 0
edited September 2019 in Free community support

I am initiating the data-table through the function in javascript. I am calling the function in change events of the controls. But after destroying and re-initiating the data-table, the row can be selected but previous selection of the row still there. How can make it one row selection at a time. Please can you advise me where is the error in my code to select the row of the data-table. I have attached the code in txt file

With Many Thanks
Pol

Answers

  • kthorngrenkthorngren Posts: 21,160Questions: 26Answers: 4,921
    edited September 2019

    One option would be to use the Select Extension.

    Currently you are using jQuery to select and deselect the rows, for example: $(this).addClass('selected');. Datatables has no knowledge of this so you will need to handle this yourself.

    You can try something like the answer in this SO thread inside your GetBreakDownLog() function.

    Kevin

  • polachanpolachan Posts: 101Questions: 50Answers: 0
    edited September 2019

    I given the suggested code still more than one row is being selected after calling the function GetBreakDownLog() seconed time. But when I call first time it is working fine . But after the change event of the month or year , the more than one is selected.
    I give the code inside GetBreakDownlog as

    $('#BreakDownLog tr').removeClass("selected");

    It would be very much appreciated if you can give suggested code

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @polachan ,

    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

This discussion has been closed.