Hi Team
I am using infragistics 2013.1 version grid and i am trying use rowselector feature and i am trying to select some rows and checked the checkbox from backend based on some data can you help me how we can do that.
i am giving you my sample code which i am trying to do but its not working
$("#prodByMeaInfra").on("iggriddatarendered", function (event, args) { $scope.$apply(function () { args.owner.element[0].rows[0].cells[0].innerHTML = "<span class=\"ui-state-default ui-corner-all ui-igcheckbox-normal\" name=\"hchk\" data-role=\"checkbox\" data-chk=\"on\"><span class=\"ui-icon ui-icon-check ui-igcheckbox-normal-on\"></span></span>"; }); });
or is there any way to keep the checked box state in same state at the time of using filter or sorting.
Please help me on this on urgent basis
Thanks
Vivek
Hello Vivek,
I'll look into it further and if it is indeed a bug or if certain improvements can be made I'll create a case for you so you can get updated once the changes regarding the issue are done and available as part of a service release.
Best regards,
Stamen Stoychev
Thanks Stamen
Thanks for your suggestion after lots of try and random checks i also implemented the same thing and its working but my self not fully satisfied with that solution
looks like bug to me Please look on this.
any way thank for helping me lots.
It seems you've hit a limitation caused by the current implementation of RowSelectors. The feature has the built-in functionality to persist selection through paging and this now interferes with your current persistent selection implementation. I went back and forth trying to find a solution which uses only options and event handlers but unfortunately suppressing this basic RowSelectors functionality is not easy without handling some internals. With this said, I think the most straightforward solution is to simply unbind RowSelector's own paging handler. This will make it harmless for your implementation. You can achieve this with the following line placed somewhere after the grid initialization:
$("#grid1").unbind("iggridpagingpageindexchanged", $("#grid1").data("igGridRowSelectors")._pageIndexChangedHandler);
I would also like to add that if you find persistent selection to be an important feature in your project, you could always log a product idea for supporting this functionality out of the box. We base our future development almost exclusively on user feedback.
i appreciate your quick response.
you are correct i took same approach and it solved my problem but this pagination created another problem for me.
seems this code is not working perfectly
$("#prodByMeaInfra").igGridSelection("selectRow", $("#prodByMeaInfra").find("tr[data-id='" + totalselectedRowsIds[i] + "']").index());
in grid when i am using filter and selecting some items and then removing filter and going to next page and when i am coming back to same page i am seeing some extra rows got selected but my collection has same items which i have inserted manually.
Can you please suggest me something on that.
If I understand your issue correctly it comes from the fact Selection is actually lost between pages as well, and this is by design. RowSelectors do try to keep it but they do it with some internals as the public API should correctly only return rows with selectable elements (which is impossible if they are not rendered due to being on another page). So when you click on a checkbox on the second page and in your handler you first remove the whole stored selection, you are no longer able to obtain the one from the previous page.
I think a viable way to solve this is to not remove the whole selected rows collection you are creating but rather modify it to match the new grid state. So your checkBoxStateChanged event handler should look like this:
checkBoxStateChanged: function (evt, ui) { // you can get the row being checked from the event args var newId = parseInt(ui.row.attr("data-id"), 10), i; for (i = 0; i < selectedRowsIds.length; i++) { if (selectedRowsIds[i] === newId) { // if it's already there the user is trying to deselect it selectedRowsIds.splice(i, 1); return; } } // the element is not found therefore needs to be added selectedRowsIds.push(newId); }
I hope this helps!