How to get display value of every rows that checked

How to get display value of every rows that checked

copsychuscopsychus Posts: 20Questions: 5Answers: 0

I tried to use with this command, but i get only data when datatable is loaded not the current value that i want => current datatable i'm added with many dropdownlist, textbox, switch => i want this data that display on screen, how to do it, please?

table.rows({ selected: true }).data().toArray()

Answers

  • kthorngrenkthorngren Posts: 21,171Questions: 26Answers: 4,922

    Sounds like you are updating the table data without using Datatables APIs to make the updates. In this case Datatables won't know about the changes and won't update it's data cache which is why you are seeing the original data. Without seeing what you are doing, a link to your page or a test case, it will be hard to provide a specific answer. You can use row().data() or cell().data() to update the Datatables data cache. Or you can use row().invalidate() or cell().invalidate() to have Datatables update is cache from the new data.

    Kevin

  • copsychuscopsychus Posts: 20Questions: 5Answers: 0

    this is what i'm doing :
    1. create datatable using ajax call backend api data
    2. each columns render with addtional textbox / dropdownlist / checkbox and etc.
    3. whenever doing change in textbox / dropdownlist / checkbox on each column in each row , the checkbox in first column also checked
    4. user click update button to select all current rowdata to backend api with ajax.
    .
    how can i update the row data ? i have jquery with whenever those textbox / dropdownlist / checked are being changed.

  • copsychuscopsychus Posts: 20Questions: 5Answers: 0

    After trying , i get new method to doing this , i use jquery call with ID selector instead but i also found another problems, this data doesn't have rowIndex on its, how can i get rowindex of each data() ?

    table.rows({ selected: true }).data().toArray()
    
  • copsychuscopsychus Posts: 20Questions: 5Answers: 0

    Is there a methods to create empty index column at second column beside checkbox column, and when i'm using this command to get row index inside this data ?
    .

    table.rows({ selected: true }).data().toArray()
    
  • copsychuscopsychus Posts: 20Questions: 5Answers: 0

    oh i already got an answer, i will use this

     var rowList = table.rows({ selected: true }).indexes();
    

    then while $.each for data().toarray(), i can call jquery id selector with index from rowList.

This discussion has been closed.