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

Telerik RadGridView with Data Form containing Child Property Collection

3 Answers 28 Views
GridView
This is a migrated thread and some comments may be shown as answers.
tk
Top achievements
Rank 1
tk asked on 31 Aug 2014, 11:36 AM
Hi,

I am a general newbie when it comes to Silverlight/Telerik. I am currently maintaining a Silvelight 4 application.

I have the following setup(using Prism, MVVM):

1) A RadGridView with a Dataform to display & edit master-detail information
2) I did this end to end and its working
3) A new requirement has come to have that DataForm to also display 2 gridviews in it
4) But the GridViews in the DataForm is not displaying any data.
5) The "SelectedItem" has two collections for these grids.

Example:

1) Suppose I have a Person, who has multiple Addresses and multiple PhoneNumbers
2) The list of people (Person collection) is displayed in the "master grid"
3) The DataForm displays
     - the Person details of the selected Person
     - Should show a grid for the Selected Person's Addresses <- Not working
     - Should show a grid for the Selected Person's Phone Numbers <- Not working
4) What do I need to do so that it binds to the selected Person's Addresses and PhoneNumbers and displays them
 
public class Person
    {
        public Person()
        {
        }
        public int Id { get; set; }
        public string Name { get; set; }
        public ICollection<Address> Addresses { get; set; }
        public ICollection<PhoneNumber> PhoneNumber { get; set; }
    }

    public class Address
    {
        public Address()
        {
        }
        public int Id { get; set; }
        public string Line1 { get; set; }
        public string Line2 { get; set; }
        public string Line3 { get; set; }
        public string Code { get; set; }
        public int PersonId { get; set; }
    }

    public class PhoneNumber
    {
        public PhoneNumber()
        {
        }
        public int Id { get; set; }
        public string Number { get; set; }
        public int PersonId { get; set; }
    }

3 Answers, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 03 Sep 2014, 04:29 PM
Hello,

I am not entirely sure why you need to display two RadGridViews inside the DataForm. Anyway, I attached a sample project that demonstrates how you can do just that.

Please examine the example and let us know how it goes.

Regards,
Boris Penev
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
tk
Top achievements
Rank 1
answered on 07 Sep 2014, 02:11 PM
Thanks for your the sample, Boris. Used bits of it to help solve my issue.

I have a quick, related question.

I have managed to get my solution working.

I am trying to then popup with the viewModel sent to through the button's command, as follows:
<code>
<telerik:RadButton Content="New Address" Command="{Binding Content.PerformShowNewAddressPopupCommand, Source={StaticResource viewModel}, Mode=TwoWay}" CommandParameter="{Binding}"></telerik:RadButton>
</code>

That Command then calls a View with a RadWindow as follows:

<code>
private void ShowNewAddressCommentWindow(PersonSearchViewModel model)
        {
            
            try
            {
                NewAddressView view = new NewAddressView();
                view.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen;
                view.PersonId = model.SelectedItem.PersonId;
                view.ShowDialog();

            }
            catch
            {
                
                throw;
            }
        }
</code>
0
Boris
Telerik team
answered on 08 Sep 2014, 04:14 PM
Hi,

I attached an updated version of my previous project. It does something similar to the code of your last post. However, I did not encounter any specific problems. Could you please elaborate a bit more on which part is hindering your success?

Regards,
Boris Penev
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
tk
Top achievements
Rank 1
Answers by
Boris
Telerik team
tk
Top achievements
Rank 1
Share this question
or