I'm developing a grid that uses paging and checkboxes. The grid keeps the state of the selected boxes when jumping between pages. But I've noticed that doing:
$('#grid1').igGrid('selectedRows');
only returns the selected rows in the current page.
How can I get all the selected rows in all the pages? Is there a way to get the primaryKey values instead of the row number of the selected rows. The row order does not help much if the user changes the sorting of the table clicking a column.
Hello guys,
I have posted detailed information on this issue at the following thread: http://es.infragistics.com/community/forums/p/74989/420809.aspx#420809
Since both discussions are on the same topic I will close this one.
If you have any further questions, comments or suggestion please post them there.
Thank you.
I'm having this same issue, but can you upload a sample solution to this problem, in Razor syntax, if possible? Thanks.
Hello ldwedari,
Unfortunately you cannot access persisted checkbox values, because they are stored in private variable.
However you can implement the following solution:
Bind to "checkBoxStateChanged" event of igGridRowSelectors and save the state of the checkbox in your array.
Here is the example code:
<script type="text/javascript"> var selectedProducts = []; $(function () { // Initialize your grid with id="grid1" //Bind to checkBoxStateChanged event and save the checkbox state in your own array $(document).delegate("#grid1", "iggridrowselectorscheckboxstatechanged", function (evt, ui) { // take the primary key value of the row. You must set primaryKey property of the grid in order for this approach to work var productId = ui.row.attr("data-id"); // save the state of the checkbox selectedProducts[productId] = ui.state; }); }); </script>
<script type="text/javascript">
var selectedProducts = [];
$(function () {
// Initialize your grid with id="grid1"
//Bind to checkBoxStateChanged event and save the checkbox state in your own array
$(document).delegate("#grid1", "iggridrowselectorscheckboxstatechanged", function (evt, ui) {
// take the primary key value of the row. You must set primaryKey property of the grid in order for this approach to work
var productId = ui.row.attr("data-id");
// save the state of the checkbox
selectedProducts[productId] = ui.state;
});
</script>
Note:
You must set primaryKey property of the grid in order for this approach to work.
Hope this helps,
Martin Pavlov,
Infragistics, Inc.
Angel,
I know that Selection feature is not persisted between pages, but the checkboxes of the RowSelector feature DO get persisted. I tested it myself, I just need to know where are they persisted and how to access them.
Thanks
Hi,
selection is not persisted across pages. In case you would like to get the primary keys, you can use something like this:
var pkValue = someSelectedrow.element.attr('data-id');
Hope it helps.
Thanks,
Angel