Using 10.2 here is the scenario I am trying to replicate from a WinForms application:
I have a webDataGrid that I want to apply some bulk row processing against a set of rows. I want to be able to hit a button and do something to each of the selected rows. I have a tried a few different ways but nothing seems to work so I'm looking for some advice.
In my winForms app I added a bool data column to my business object and included that in the databinding to the grid. Then on my button click using LINQ I could grab the subset of datarows that had the data column set to true and do my processing. This was nice and easy. I was also able to easily add a 'Select/Clear All' option. My grid was bound to a List<MyObjects>
To further complicate things we have a filtering mechanism driven by an associated control. As I click nodes in a tree I am adding/removing filters from the underlying data. In the winForm this was easy. If the row was visible or hidden it still retained its selected status so as the filtering was toggled the selections remained.
In the webForms this is proving tricky as I'm trying to avoid endless postbacks and screen flashes. I am willing to live with less retention of selection on items that get filtered out but I'm having a horrendous time managing this with a disconnected state.
Including a 'SelectAll/ClearAll' button also seemed to complicate things....
Some of my questions are:
1 - If I have a list of selected items on the client, how do I get that back to the server when postbacking from a separate control? So I hit my button to ExportAllSelectedItems and I need to know on the server the subset of the dataset that is selected.
Right now I have to re-bind my grid on each postback and I can't seem to find any selected rows in my page_load if(IsPostBack) section.
2 - If I did an autopostback on 'RowSelectionChanged' and then kept my 'IsSelected' flag set on the server how do I re-set the selected rows again? Can I do that in the OnInitializeRow?
3 - does this get easier if I use an objectDataSource binding vs. directly rebinding to the List<> on every postback?
Anyhow this seems like a farily common business scenario but it seems with all the combinations of settings and bindings etc. that it is getting far more complicated that it is.
Thanks
jack
Hi Jack,
It has been a while since your post, however in case you still need assistance I would be glad to help.
To answer your first question, the list and indexes of the selected rows in the grid are being passed to the server and you can access them using:
WebDataGrid1.Behaviors.Selection.SelectedRows[i]
Similarly you can select the rows on the server:
WebDataGrid1.Behaviors.Selection.SelectedRows.Add(WebDataGrid1.Rows[i])
The specific way that you are binding your grid should not affect the row selection.
Please contact me if you have any questions.
Best Regards,Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support