Richard Harrigan
Top achievements
Rank 1
Richard Harrigan
asked on 01 Apr 2011, 01:50 AM
Hi,
I want to totally clear out a hierarchical grid for reuse. I tried RadGridView.Columns.Clear but that only cleared out the first level. How can I clear the columns for all levels.
Thanks
Rich
I want to totally clear out a hierarchical grid for reuse. I tried RadGridView.Columns.Clear but that only cleared out the first level. How can I clear the columns for all levels.
Thanks
Rich
6 Answers, 1 is accepted
0
Hi Richard Harrigan,
You may try utilizing this recursive approach:
You should have in mind that only the RadGridView instances that are already included in the visual tree will get "cleared". In order to have a child table RadGridView instance loaded into the visual tree, its parent row should have been expanded at least once.
Regards,
Ivan Ivanov
the Telerik team
You may try utilizing this recursive approach:
private
static
void
DeepClear(RadGridView grid)
{
grid.Columns.Clear();
IEnumerable<GridViewRow> rows = grid.ChildrenOfType<GridViewRow>().Where(s => s.Item !=
null
);
foreach
(GridViewRow row
in
rows)
{
if
(row.ChildrenOfType<RadGridView>().Count > 0)
{
DeepClear(row.ChildrenOfType<RadGridView>().First());
}
}
}
Regards,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard Harrigan
Top achievements
Rank 1
answered on 01 Apr 2011, 05:07 PM
Hi,
I tried it out but it did not work for me. The thing that I noticed was that there were no children of type <GridViewView>. There was children of type <GridViewDataControl>. I tried changing the code to that type and while it did iterate DeepClear it had no effect. All the rows were cleared out but when I expanded the reloaded RadGridView what was displayed was and extra empty header with no columns..
Thanks
Rich
I tried it out but it did not work for me. The thing that I noticed was that there were no children of type <GridViewView>. There was children of type <GridViewDataControl>. I tried changing the code to that type and while it did iterate DeepClear it had no effect. All the rows were cleared out but when I expanded the reloaded RadGridView what was displayed was and extra empty header with no columns..
Thanks
Rich
0
Hello Richard Harrigan,
I have prepared a sample project for you that demonstrates my approach. Please, inform us if this solution meets your requirements.
Greetings,
Ivan Ivanov
the Telerik team
I have prepared a sample project for you that demonstrates my approach. Please, inform us if this solution meets your requirements.
Greetings,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard Harrigan
Top achievements
Rank 1
answered on 04 Apr 2011, 04:59 PM
Hi
I tried the sample but it did not work for me. It cleared out all the rows but the empty header was still in place including the row expansion icon. I need everthing cleared oit because I am changing to a new hierarchy structure.
I am using
Version 2010.3.1314.1040
Runtime version v2.0.50727
Thanks
Rich
I tried the sample but it did not work for me. It cleared out all the rows but the empty header was still in place including the row expansion icon. I need everthing cleared oit because I am changing to a new hierarchy structure.
I am using
Version 2010.3.1314.1040
Runtime version v2.0.50727
Thanks
Rich
0
Hi Richard Harrigan,
Obviously I have misunderstood you, because you have mentioned clearing the columns of the child RadGridViews in your first post. If you want to completely get rid of your current hierarchical structure you may try using this: testGrid.ChildTableDefinitions.Clear();
Kind regards,
Ivan Ivanov
the Telerik team
Obviously I have misunderstood you, because you have mentioned clearing the columns of the child RadGridViews in your first post. If you want to completely get rid of your current hierarchical structure you may try using this: testGrid.ChildTableDefinitions.Clear();
Kind regards,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Richard Harrigan
Top achievements
Rank 1
answered on 05 Apr 2011, 07:40 PM
Thanks, that did the trick. I also, needed to know how to clear out rows so your effort was not wasted.
Thanks
Rich
Thanks
Rich