Telerik RadGridView with Data Form containing Child Property Collection

4 posts, 0 answers
  1. tk
    tk avatar
    2 posts
    Member since:
    Mar 2014

    Posted 31 Aug 2014 Link to this post

    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; }
        }
  2. Boris
    Admin
    Boris avatar
    276 posts

    Posted 03 Sep 2014 Link to this post

    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.
     
  3. DevCraft banner
  4. tk
    tk avatar
    2 posts
    Member since:
    Mar 2014

    Posted 07 Sep 2014 in reply to Boris Link to this post

    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>
  5. Boris
    Admin
    Boris avatar
    276 posts

    Posted 08 Sep 2014 Link to this post

    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.
     
Back to Top