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

How to populate the child grid in Hierarchy

10 Answers 142 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marc Roussel
Top achievements
Rank 2
Marc Roussel asked on 30 Oct 2010, 11:33 AM
Hi,

Sorry but after reading the documentation and looking at the demo, I did not see how to populate the child grid.  I certainly missed a point somewhere.

I've read this one : http://www.telerik.com/help/silverlight/gridview-basic-hierarchies.html

I have 2 seperate collections of data with a relation.  Ok I did set the hierarchy as described in the documentation and I can see that the grid acts like expected.  I see the parent data but of course since I don't know where to put my second collection I see nothing when I press the + button.  Where's the second ItemsSource, How do I access the second grid ?

The grid have my first collection of data in the ItemsSource and the grid is ready for hierarchy.  All I need now is to populate the child grid.  Thank you for any hints

10 Answers, 1 is accepted

Sort by
0
Marc Roussel
Top achievements
Rank 2
answered on 30 Oct 2010, 03:31 PM
By the way, I have 2 collections of DataContract object that comes from WCF call
I also tried this code which have a collection of Application inside my Customer Object which I populate

foreach (GAM_Customer Customer in _Customers)
    Customer.Applications = new ObservableCollection<GAM_Application>(_Applications.Where<GAM_Application>(a => a.CustomerId == Customer.CustomerId).ToList());

I still don't see the data in the child grid
I can see that everything is tehre in place which is each Customer object having it's own collection of Applications
0
Marc Roussel
Top achievements
Rank 2
answered on 30 Oct 2010, 03:39 PM
The code for the relation is here :

rgvCustomers.ChildTableDefinitions.Clear();
GridViewTableDefinition gtd = new GridViewTableDefinition() { Relation = new Telerik.Windows.Data.PropertyRelation("CustomerId") };
rgvCustomers.ChildTableDefinitions.Add(gtd);
0
Maya
Telerik team
answered on 02 Nov 2010, 10:48 AM
Hello Marc Roussel,

I am sending you a sample project illustrating one possible way for defining Hierarchy Grids and setting their ItemsSource-s, using WCF RIA Services.
Let me know if it helps and corresponds to your requirements.
 

Kind regards,
Maya
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
Marc Roussel
Top achievements
Rank 2
answered on 02 Nov 2010, 02:56 PM
When I run the application I get this attached
0
Marc Roussel
Top achievements
Rank 2
answered on 02 Nov 2010, 03:08 PM
Sorry, there's nothing fonctional for me in there as I'm using just PURE WCF call,


[DataContract]
public class Customer
{
}

and

[DataMember]
Properties
{
}

A class which comes from a simple WCF call.

Here's an example of it :
[DataContract]
public class GearPhoneItem
{
    #region ' Fields '
        private int _PhoneID;
        private string _Ext;
        private string _PersonName;
        private string _Phone;
        private string _Department;
        private string _Email;
        #endregion
  
    #region ' Properties '
        [DataMember]
        public int PhoneID
        {
            get { return _PhoneID; }
            set { _PhoneID = value; }
        }
        [DataMember]
        public string Ext
        {
            get { return _Ext; }
            set { _Ext = value; }
        }
        [DataMember]
        public string PersonName
        {
            get { return _PersonName; }
            set { _PersonName = value; }
        }
        [DataMember]
        public string Phone
        {
            get { return _Phone; }
            set { _Phone = value; }
        }
        [DataMember]
        public string Department
        {
            get { return _Department; }
            set { _Department = value; }
        }
        [DataMember]
        public string Email
        {
            get { return _Email; }
            set { _Email = value; }
        }
        #endregion
}


When back from the GetCustomer and GetApplication , I populate my collections and this is done for 2 separate collection with a relation between them

The class above is just an example of the object coming by from the Async call to the WCF service .svc.  There's no mention of Domain in there.  It's a pure call, nothing fency !
0
Maya
Telerik team
answered on 02 Nov 2010, 03:09 PM
Hello Marc Roussel,

Basically, the reason for the exception is not caused by the RadGridView and you may use the project for a reference on the approach for setting the ItemsSource of the grids. However, the error you are getting may be due to the fact the .Web project is not the Start-up one. 

 

Greetings,
Maya
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
Marc Roussel
Top achievements
Rank 2
answered on 02 Nov 2010, 03:12 PM
Let say I have 2 collections of object
with a key relation in each different object

how would you populate the grid in a hierarchy way ?
Also, if it's about adding a collection of application in each distinct Customer,  that is something I already tried and nothing seems to appear on the chiuld grid

Collection 1
    Customer1.CustomerId
        Collection2
            Application1.CustomerId
            Application2.CustomerId
    Customer2.CustomerId
        Collection2
            Application3.CustomerId
            Application4.CustomerId
    Customer3.CustomerId
        Colleciton2
            Application5.CustomerId
            Application6.CustomerId
0
Marc Roussel
Top achievements
Rank 2
answered on 02 Nov 2010, 03:18 PM
The Project.Web is really the one as startup and the .aspx is the page as startup
however it doesn't work.  I tried to read everywhere where I have to take some code example in there that reflect what I need and I do not seem to figure out
0
Marc Roussel
Top achievements
Rank 2
answered on 02 Nov 2010, 03:49 PM
I already tried the collection of application INSIDE each customer and as I already mentioned, this was giviming only a blank child grid
I will give you a repro project so we can work out this in the repro
0
Marc Roussel
Top achievements
Rank 2
answered on 02 Nov 2010, 05:14 PM
Created the ticket number 362861
Thank you
Tags
GridView
Asked by
Marc Roussel
Top achievements
Rank 2
Answers by
Marc Roussel
Top achievements
Rank 2
Maya
Telerik team
Share this question
or