binit92
binit92

Reputation: 95

How do I get selected value in Jquery Datatable in String format

function unenroll(){
       
        var myTable = $('#enrollment_info').DataTable();
        
        alert("all data is "+allData);
        var selectedrows = myTable.rows('.selected' ).data();
        alert("selected rows"+selectedrows);        
        alert("selected rows length is "+ selectedrows.length)
     }

selected rows is showing output but in object format. How can I get it in String format. This table gets populated by a json from Servlet.enter image description here

Upvotes: 0

Views: 1289

Answers (1)

SlimPickens
SlimPickens

Reputation: 61

JSON.stringify(); is one direct solution if I'm understanding your question correctly. You should probably decide exactly what data you need from the table and be a bit more direct about retrieving it.

function unenroll(){
       
        var myTable = $('#enrollment_info').DataTable();
        
        alert("all data is "+allData);
        var selectedrows = JSON.stringify(myTable.rows('.selected' ).data());
        alert("selected rows"+selectedrows);        
        alert("selected rows length is "+ selectedrows.length)
     }

Upvotes: 2

Related Questions