This question is locked. New answers and comments are not allowed.
Hi,
I am in a scenratio where I have grid inside grid (HierarchyChildTemplate). Not all rows in outer grid have children records, so inside grid is visible for rows that do. I allow user to add/remove/edit children data.
Lets say that I have Groups and Products
Group A
Group B
Product A
Product B
GroupC
GroupD
Product C
Product D
AS it can be seen, ProductA and B belong to GroupB, and ProductC and D belong to GroupD. GroupA and GroupC don't have products in them.
1) If I click on some button, which executes a command on ViewModel, and some product is added to GroupA, RadGridView will not automatically display children records. In order for new product ProductE to appear under GroupA, I needed to execute below code each time a new product is added:
Is this the correct way to do this, and why the grid doesn't sense the notifications from ObservableCollection of Products?
2) If I remove ProductC and ProductD, then GroupD should hidechild grid. However, if at this point I insert a new product inside GroupD, child grid should appear again. I am having difficulties in implementing this requirement. If I bind to Visibility, I could solve the problem with inserting / removing products, since I am ading/removing in ViewModel, I just need to set value for ProductsExist in AddProduct/RemoveProduct commands.
However, the problem appears during data loading, Since this is asyncronous process, I would need to set some flags to know when loading is finished, so I can correct the value for ProductsExist.
I am finding all this a bit dirty. What are your suggestions to solve this problems of appearance with inside grid? And why is this not automatic, if child grid is bound to ObservableCollection<Product>? It can pick up notifications from INCC and react accordingly.
Regards,
Goran
I am in a scenratio where I have grid inside grid (HierarchyChildTemplate). Not all rows in outer grid have children records, so inside grid is visible for rows that do. I allow user to add/remove/edit children data.
Lets say that I have Groups and Products
Group A
Group B
Product A
Product B
GroupC
GroupD
Product C
Product D
AS it can be seen, ProductA and B belong to GroupB, and ProductC and D belong to GroupD. GroupA and GroupC don't have products in them.
1) If I click on some button, which executes a command on ViewModel, and some product is added to GroupA, RadGridView will not automatically display children records. In order for new product ProductE to appear under GroupA, I needed to execute below code each time a new product is added:
groupGrid.ItemContainerGenerator.ContainerFromItem(groupGrid.SelectedItem) as GridViewRow;
if (row != null)
{
row.IsExpandable = true;
row.IsExpanded = true;
}
Is this the correct way to do this, and why the grid doesn't sense the notifications from ObservableCollection of Products?
2) If I remove ProductC and ProductD, then GroupD should hidechild grid. However, if at this point I insert a new product inside GroupD, child grid should appear again. I am having difficulties in implementing this requirement. If I bind to Visibility, I could solve the problem with inserting / removing products, since I am ading/removing in ViewModel, I just need to set value for ProductsExist in AddProduct/RemoveProduct commands.
Visibility="{Binding ProductsExist, Source={StaticResource viewModel}, Converter={StaticResource boolToVisibilityConverter}}"
However, the problem appears during data loading, Since this is asyncronous process, I would need to set some flags to know when loading is finished, so I can correct the value for ProductsExist.
I am finding all this a bit dirty. What are your suggestions to solve this problems of appearance with inside grid? And why is this not automatic, if child grid is bound to ObservableCollection<Product>? It can pick up notifications from INCC and react accordingly.
Regards,
Goran