This is a migrated thread and some comments may be shown as answers.

Binding not working properly

7 Answers 110 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Snehal
Top achievements
Rank 1
Snehal asked on 03 Jul 2010, 07:24 AM

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

Sort by
0
Pavel Pavlov
Telerik team
answered on 05 Jul 2010, 07:45 AM
Hi Snehal,

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
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
Snehal
Top achievements
Rank 1
answered on 06 Jul 2010, 05:33 AM
Hi Pavel,

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?

 

0
Pavel Pavlov
Telerik team
answered on 06 Jul 2010, 01:28 PM
Hello Snehal,

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
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
Snehal
Top achievements
Rank 1
answered on 07 Jul 2010, 05:02 AM
HI
yes both grid bound with observation collection.
0
Snehal
Top achievements
Rank 1
answered on 09 Jul 2010, 07:51 AM
Sorry that Parent grid work propertly with ObservableCollection.

But Nested grid need to rebind again.

 

0
Pavel Pavlov
Telerik team
answered on 09 Jul 2010, 12:51 PM
Hello Snehal,

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
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
gaurav
Top achievements
Rank 1
answered on 02 Aug 2019, 04:18 PM

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>

Tags
GridView
Asked by
Snehal
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Snehal
Top achievements
Rank 1
gaurav
Top achievements
Rank 1
Share this question
or