How to check the checkbox basing on the column data in jquery data table.

How to check the checkbox basing on the column data in jquery data table.

pravspravs Posts: 29Questions: 4Answers: 0

Hi i have the situation like this i need to check the data table check box basing on the 2nd column data value ... please help me out its urgent

Replies

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

    You can use columns.render to generate the checkbox HTML based on the value in the column.

    Kevin

  • pravspravs Posts: 29Questions: 4Answers: 0

    But My condition is different after loading of data i need to check the check box basing on the particular column value

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

    Not sure I understand. Here is an example I put together previously. Is this what you are looking for?
    http://live.datatables.net/dalozuni/1/edit

    Kevin

  • Rob BrunRob Brun Posts: 56Questions: 2Answers: 14
    edited July 2017

    Hi pravs, Maybe something like this

     "createdRow": function (row, data, index) {
    
                    if (data["DataInSecondCol"] === "MyCondition") {
                        $(row).addClass("selected");
                    } 
                },
    
    

    https://datatables.net/reference/option/createdRow

    Shay

  • pravspravs Posts: 29Questions: 4Answers: 0

    No yar it is not what i want. I am attaching the image please find out. Basing on the third column cell value, That particular row check box have to check .. for example if iam giving the value REV00000447 that particular row checkbox have to check . Please help me out

  • pravspravs Posts: 29Questions: 4Answers: 0
    edited July 2017

    This will be done after data table data load

  • kthorngrenkthorngren Posts: 21,310Questions: 26Answers: 4,948
    edited July 2017

    I updated my example:
    http://live.datatables.net/sipavula/1/edit

    Changed the code to check the office column. If itcontains "New York" then set the checkbox in column 2. columns.render executes when Datatables displays the data for that column. In the case of my example the data is already loaded when Datatables is initialized.

    Kevin

This discussion has been closed.