I have a RadGrid that a user can apply filters to. Once they click on a submit button, I want to extract all filtered rows and then process the data from there.
Is there a built in function to only retrieve the filtered data?
Thank you.
12 Answers, 1 is accepted
Once you apply a data operation to RadGridView (filtering, grouping, sorting) the resulted view is stored in the ChildRows collection of the template. So you can access your rows from there.
More information regarding this matter is available here: http://www.telerik.com/help/winforms/gridview-rows-rows-vs-childrows.html.
Greetings,
Stefan
the Telerik team
This seems to be for WinForms, I am using a web application with the AJAX controls.
I can't seem to find how to implement the ChildRows using a RadGrid? I doesn't have any NestedViews, I just want to get the filtered rows from a RadGrid
Thanks
protected
void
uxSendMail_Click(
object
sender, EventArgs e)
{
int
itemCount = 0;
uxSitesGrid.AllowPaging =
false
;
uxSitesGrid.Rebind();
foreach
(GridDataItem gridRow
in
uxSitesGrid.Items)
{
itemCount += 1;
}
System.Windows.Forms.MessageBox.Show(itemCount.ToString());
uxSitesGrid.AllowPaging =
true
;
uxSitesGrid.Rebind();
}
Is there a way to keep the status accros paging?
Please note that RadGrid does not preserve the selected items or the state of Template controls upon performing database operations. Therefore, although you will get the selected items successfully on any other server event, their state will reset when you fire a command regarding a datasource request.
You could save the selected items in a collection variable and use it when necessary:
http://www.telerik.com/help/aspnet-ajax/grid-persist-selected-rows-client-sorting-paging-grouping-filtering.html
or
http://www.telerik.com/help/aspnet-ajax/grid-persist-selected-rows-on-sorting.html
I hope this will prove helpful.
Kind regards,
Eyup
the Telerik team
Thanks for the response. What I ended up doing was to handle the checkbox change event and then add/remove the DataKey to a List<string> and then at the end remove those from my filtered grid.
Bit of a work around, but working 100% now.
Thank you.
Hello,
I have an issue in regards to the topic specified above.
I have a radgrid in a winform where data is populated for the user. Then, when the data is populated, Users have to apply some filters ,depend on the request, and submit process via clicking a button on the screen.
The problem is that I want to get the current data on the grid (after applying the filters) but I keep struggleing with that. Please it is quite urgent. Can you help me? Let me show you the two options that I am doing (none of them are working for me)
1st Option
System.Data.DataTable dt_filtered = new DataTable();
string filterexpression = string.Empty;
filterexpression = radGridView1.MasterTemplate.FilterDescriptors[0].Expression;
dt_filtered = dtGrid.AsEnumerable().AsQueryable().Where(filterexpression).CopyToDataTable();
This option is giving me an error "LinqDataSource, Repeaters and "Expression Expected" exception".
The second option was to use this.radGridView1.ChildRows but since this is returning a RowInfo, we do not know how to add those rows into a datatable.
Pleasee heelp :(
Thanks so much in advance!
Note that RadGridView exposes two collections that contain data rows:
- Rows - contains all data rows that belong to RadGridView. Data operations such as grouping, sorting, filtering, etc. do not change the content of the collection or the order in which the row objects exist in the collection.
- ChildRows - returns the data rows that are currently represented by RadGridView in the order in which they appear. The collection is modified every time a data operation (grouping, sorting, filtering) occurs.
You can iterate the ChildRows collection where each data row has a DataBoundItem property storing the source record of the associated collection as DataSource. Thus, you can fill a DataTable with the filtered data.
Off topic, note that most of the forum threads are reviewed by Telerik representatives and sometimes we address the questions asked by our customers in the forums as well. However, a post in the forum doesn't guarantee you a response from the Telerik support team. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
"Child Rows" does not work if filtered data spans across multiple pages.
It accounts records only from current page.
Any solution for looping through all filtered records (including all pages)?
Hi, Betsy,
Please refer to the following KB article which I believe would be suitable for your scenario: https://docs.telerik.com/devtools/winforms/knowledge-base/get-all-filtered-rows-in-gridview-with-paging
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Thanks Dess
It worked perfectly as required.