How to to show only selected rows from an integer array of IDs
How to to show only selected rows from an integer array of IDs
I have a drop down with checkboxes in it. When I select multiple items, I have a method which gets those IDs in an integer array. In my data table one of the column, lets say 'User_ID:name' has those IDs. I want to loop through the data table and show only rows of selected IDs in the integer array. If array is empty, no rows should be visible.
I wrote a method, but it's only showing me only 1 row and it keeps overwriting that row when looping through.
var Gridupdate = function () {
int[] checked = Checkbox.getCheckedIds(); /// integer array of selected IDs from checkbox
if (dtable) {
for (i = 0; i < checked.length; i++) {
dtable.column("User_ID:name").search(checked[i].toString()).draw();
}
}
}
This question has an accepted answers - jump to answer
Answers
You will need to execute the
column().search()
once using a regex search. You will need to combine all the values into one string with each id separated by a|
. See this example doing something similar:http://live.datatables.net/xehexoye/1/edit
Kevin