I have one truck gridview. in that i have RowDetailsTemplate which contains one more gridview order details. This order detail will bind on truck's LoadingRowDetails event.
Now am draging order from some other grid & droping to truck grid. And binding Truck grid again. (As i am not know how to find direct order grid gridview..if anybody can help on this then its great for me.)
Now what happens if GridViewToggleRowDetailsColumn is visible & am droping to truck grid. it will not update order detail grid.
For this i have to do like
rgvTruckList.ItemsSource =
Nothing
rgvTruckList.ItemsSource = objTruckList
then its working fine. but it takes more time.
Thanks...!!!
7 Answers, 1 is accepted
In order to refresh th the RadGridView UI after update in the source collection there are two possible approaches :
1. The source collection should implement the INotifyCollectionChanged interface . This way RadGridView will automatically sense any added items and will update the UI respectively.
or
2. If implementing the INotifyCollectionChangedinterface is not applicable to your source collection ,
you can call the Rebind() method of RadGridView , after adding a new item to the collection.
or
3. Use ObservableCollection for the ItemsSource ( which is capable of notifying if any item has been added /removed/deleted.
Best wishes,
Pavel Pavlov
the Telerik team
Thanks for reply. I opt Rebind option & it worked fine.
Need to know 2 things.
1) As you suggest me 3rd option for ObservableCollection. same thing am using an binding to grid but it doesn't automatically update. In rowdetailstemplate i used another grid. may be for this reason it is not updating?
2) As i asked u can get direct control of rowdetailstemplate grid?
right now am finding control in LoadingRowDetails event only with this.
Dim
rgbOrderDetails As RadGridView = DirectCast(e.DetailsElement.FindName("rgvOrderDetails"), RadGridView)
But can i get directly rgvOrderDetails Directly & bind whenever i required?
Ok, you say the root grid is bound to an Observable collection, but is the nested grid bound to an observable collection as well ?
Best wishes,
Pavel Pavlov
the Telerik team
yes both grid bound with observation collection.
But Nested grid need to rebind again.
I could hardly guess what may be the problem . I may have a look at your project and step over your code to find the problem . To be able to attach the project , you may need to open a support ticket.
Greetings,
Pavel Pavlov
the Telerik team
I am facing a problem with Binding in UI in WPF too. So, I have a self referencing hierarchical grid and there are some items that have subordinates while some do not. The item source of the grid is an object of ClassA and the child grid is created in the code behind file using the following code in the DataLoading method of the grid:
private void FundGrid_DataLoading(object sender, GridViewDataLoadingEventArgs e)
{
GridViewDataControl dataControl = (GridViewDataControl)sender;
if (dataControl.ParentRow != null)
{
dataControl.GridLinesVisibility = GridLinesVisibility.None;
dataControl.ShowGroupPanel = false;
dataControl.AutoGenerateColumns = false;
dataControl.CanUserFreezeColumns = false;
dataControl.IsReadOnly = true;
dataControl.ChildTableDefinitions.Clear();
GridViewDataColumn column = new GridViewDataColumn();
column = new GridViewDataColumn();
dataControl.Columns.Add(column);
column = new GridViewDataColumn();
column.DataMemberBinding = new Binding("Name");
dataControl.Columns.Add(column);
dataControl.Columns[0].CellTemplate = this.Resources["ChildButton"] as DataTemplate;
dataControl.GridLinesVisibility = GridLinesVisibility.Both;
}
}
So, the subordinate elements are visible when we click on the + sign for the rows that have subordinates but the problem is that those subordinates are also available outside of the hierarchy.
e.g If the parent elements are A, B, C and D and a, b, c and d are respective child elements, the elements a,b,c and d are visible both inside element A,B,C and D and outside it.
Can you point me in the right direction and let me know what am I doing wrong? I have the following in the Main Grid as Child Table Definition:
<telerik:RadGridView.ChildTableDefinitions>
<telerik:GridViewTableDefinition>
<telerik:GridViewTableDefinition.Relation>
<telerik:TableRelation IsSelfReference="True">
<telerik:TableRelation.FieldNames>
<telerik:FieldDescriptorNamePair
ParentFieldDescriptorName="Id"
ChildFieldDescriptorName="InternalParentId" />
</telerik:TableRelation.FieldNames>
</telerik:TableRelation>
</telerik:GridViewTableDefinition.Relation>
</telerik:GridViewTableDefinition>
</telerik:RadGridView.ChildTableDefinitions>