Trying to get get the row IDs using rows().ids()
Trying to get get the row IDs using rows().ids()
jLinux
Posts: 981Questions: 73Answers: 75
I was hoping to get just an array of the row IDs specified via rowId
, but when I output the array (after selecting a few rows), it logs more details about the array than I need: ["1", "2", "3", context: Array[1], selector: Object, ajax: Object]
, definitely not sure where its getting ajax
from..
Heres the example I have: http://live.datatables.net/qajimusu/1/edit?js,output
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Whats weird, is when I re-init the DT API via the JS console, it works fine, but when I click on something I have set to output
table.rows( { selected: true } ).ids()
to the console (Via something like$().on('click'
, it will show all the extra info, (which, im assuming, is the API)http://d.pr/i/1fQzy
So how do I have it only return the IDs array?
Im not sure why this would return the API anyways really... I mean if you just need an array of the selected asset IDs, id think throwing the array into the response would hinder things, like in this situation. But then again, maybe im either doing it wrong, or just dont see the use of the API in the return
Bump? :-D
This is a problem I actually didnt figure out 20 minutes after posting about it, heh
Use the
toArray()
method - otherwise you are getting an DataTables API instance (which is what theajax
etc objects are).It returns an API instance for consistency with the rest of the API and to support chaning. For example you might want to use
map()
oreach()
with it.Allan
Thats awesome! Thanks @allan, you're the man