Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

How to get all row ids in datatables via jQuery


Hello;

In metronic_v6.0.6 datatables, I want to get all row Ids, but I couldn't find a way. I can read this when all rows selected. I want to do the same even if no row is selected.

Thank you so far.

Note: The jQuery code I use for reading selected ones; $("#m_datatable_Orders").KTDatatable().checkbox().getSelectedId();


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


Hi,

You can use jquery to get data for each row.


$("#kt_datatable").find("tr").each(function() {
var row = $(this).data("obj");
console.log(row);
// find id in the row variable
});


Thanks



Thank you Faizal, but this code lists only rows listed on the page. I need all the RecordIds the datatable fetched from database. For example there are 3,500 rows and we display only 50 of them. I need 3,500 Ids instead of 50.

I know Metronic datatable keeps this information on the client side, but I couldn't read it in proper way.



Hi,

If the data is being kept on the client-side, all data can be retrieved from datatable.originalDataSet variable.

Please try to get the ID of all records from this variable.

Thanks


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(