I am using the WebDataGrid with the Paging and Selection behaviours.
How can I select all rows by pressing a button? Currently I've tried something like the following:
// Disable paging so that all rows are accessible from the Rows collection
bool paged = Behaviors.Paging != null && Behaviors.Paging.Enabled; if (paged) { Behaviors.Paging.Enabled = false; } // Select all the rows foreach (GridRecord row in Rows) { if (!selection.SelectedRows.Contains(row)) { selection.SelectedRows.Add(row); } } // If the grid was previously paged, re-enable the paging if (paged) { Behaviors.Paging.Enabled = true; }
But this doesn't work. Can anyone please offer any assistance?
Actual, this does work, but for some reason the SelectedRows count is 0 when the ITemplates are initialised.
Hello Will,
there is a new feautre in 10.3 - Persistent Selection. Try to set EnableCrossPageSelection="true" :
<ig:Selection CellClickAction="Row" RowSelectType="Multiple" EnableCrossPageSelection="true"> </ig:Selection>
Then SelectedRows count shouldn't be 0.
Hope this helps
That's kind of irrelevant to my initial post. I'm using cross page selection, but my question was:
"How can I select all rows by pressing a button?"
The code I provided worked fine, it was just another issue with the grid templates that made me think it wasn't working.
So, for anyone else wanting to get all rows while using paging, you need to disable paging first and then re-enable it when you're done. Incredibly annoying; I don't see why IG can't implement a method like 'GetAllRows()' for when paging is enabled.