Hello,
I'm using IgGrid with the "enableCheckBoxes: true" parameter.My goal is to define rows that will be checked at initialization.I would only allow selection click on the checkbox and not click on the line.
{ name: "Selection", mode: "row", multipleSelection: true, activation: false, //Avoid the selection by clicking the row rowSelectionChanging:function(evt, ui) { return false; },},
{ name: "Paging", type: "local", pageSize: 7, /* I check first row programatically */ pagerRendering: function (evt, ui) { $("#grid1").igGridSelection("selectRow", 0); }},
The first row is checked and selected. But when I click on the checkbox already checked by default, the row does not deselect.Therefore, if I check the second line, I see the first 2 rows checked and selected instead of the first one only.
Please find an image to illustrate my issue and the jquery sample in the attached archive.
Thank you for your help,
Olivier Hélin
Hello Olivier,
It seems the issue is caused by some problem in the rendering routine. There are two ways to easily workaround it. The first way is to define Paging after RowSelectors and Selection. Have in mind that apart from a few very specific cases there shouldn't be any difference in the grid's behavior based on the order features are defined. We'll certainly look into it and provide a fix for the future service releases.
The other solution, which I personally recommend, is to move your selection logic to the rendered event of the grid itself and the pageIndexChanged event of Paging. I am attaching your sample with this solution implemented. Generally speaking, the Paging's pager events are best used to attach some logic specific to the additional dom created/changed for the pager, while logic related to the newly rendered data rows is best handled on pageIndexChanged. And since it won't get fired during the grid's initialization, you should add the same handler for the i.e. "rendered" grid event.
I hope this helps!
Best regards,
Stamen Stoychev
Hello Stamen,
My grid is bound several times and event rendered is called only once. What do you advise me to initialize the state of the checkboxes in this case?Thank you,Olivier
Thank you for your replies.
In case of rebinding the grid, is there a reason why you cannot directly select the desired rows immediately after calling DataBind on the grid ?
I am attaching a slightly modified version of Stamen's sample illustrating this.
Hope this helps.