Inherit from GridViewTemplate

2 posts, 0 answers
  1. Marco
    Marco avatar
    84 posts
    Member since:
    Apr 2011

    Posted 20 Jul 2015 Link to this post

    Hi Telerik team.

    I have a question about the RadGridView. I use in my application multiple gridview which have in common a lot. I have made some class which inherit from GridViewTemplate to represent my buisness object. This let me use the same grid in multiple Template.

    But I have tried to go to the next step in using these Template on a hierarchical Grid (by extending them to add one column for the relation with the parent grid). And then I came in trouble because the template on the main level should be a MasterGridViewTemplate (or inherit from it) and the secondary template should be a GridViewTemplate (or inherit from it BUT not from MasterGridViewTemplate).

    Let see an example:

    I have two business object with one hierarchical: Customer and order.

    I create two class CustomerGridViewTemplate and OrderGridViewTemplate which inherits from MasterGridViewTemplate. I can use theses template to build  grid which show a list of customer or a list of order.

    Now, I want to build a hierarchical Grid which show customer and their relative order so I create a new class CustomerOrderGridViewTemplate which inherits from OrderGridViewTemplate (it just add a new column with client ID). I use the CustomerGridViewTemplate as MasterTemplate and I add the CustomerOrderGridViewTemplate in the template collection and create a relation. This doesn't work (only the master template display). If OrderGridViewTemplate inherits from GridViewTemplate instead of MasterGridViewTemplate the two grid display correctly but I can't use anymore OrderGridViewTemplate in other Grid as MasterTemplate.

    I don't understand why a custom template inheriting from MasterGridViewTemplate couldn't be used as secondary template. Any help or explanation will be welcome.

  2. Hristo Merdjanov
    Hristo Merdjanov avatar
    664 posts

    Posted 23 Jul 2015 Link to this post

    Hello Marco,

    Thank you for writing.

    RadGridView is designed to work with only one MasterGridViewTemplate, when there is hierarchical data the type of the inner templates needs to be GridViewTemplate. These two classes are different and the latter one contains implementation specific to displaying a single level of hierarchical data.

    Additional information is provided in the following documentation article:

    I hope this information is useful. Should you have further questions please do not hesitate to write back.

    Hristo Merdjanov
    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 Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top