Using RadGridView inside a custom control

2 posts, 0 answers
  1. Barry
    Barry avatar
    90 posts
    Member since:
    Jul 2011

    Posted 30 Nov 2011 Link to this post

    I'm trying to create a control that ties together a RadGridView with a RadTimeBar and AreaSparkline into a single control that can accept an itemssource that will fill the gridview and set the time bar and fill the sparkline. The issue that I'm having is that I can't figure out how to get the itemssource to be type independent or how to have the itemssource be filled when the control is loaded.

    When you set the itemssource on a RadGridView the gridview doesn't care what type the object is in the collection, it just takes that collection and fills the gridview with it. I would like that functionality for my control. I could just have my control inherit the RadGridView and use its itemssource, but I need the gridview to be loaded with items that are dependent on the selected dates in the time bar. I can inherit from RadAreaSparkline and use its itemssource, but for some reason when I do that the itemssource doesn't fill when the control is loaded as it does with the RadGridView. The data only appears there when I change the data after it has been initialized. I don't understand this.

    Attached is a picture of what it looks like... this example is not a single control, but the separate controls, all set separately on the page. I would like to put them all together into a single control that you only have to set an itemssource for. The control would then set the periodstart and periodend, selectionstart and selectionend on the time bar to defaults based on a property in the itemssource and fill areasparkline and the gridview with the items.

    Is there any way to set a type independent itemssource dependency property that I can use for the control? Why does the RadGridView fill when I inherit from it and fill the itemsource and the RadAreaSparkline does not?

    Any help would be greatly appreciated.

  2. Hristo
    Hristo avatar
    408 posts

    Posted 05 Dec 2011 Link to this post

    Hi Barry,

    Our local tests do not show any issues related to RadAreaSparkline and inheriting from it seems to work correctly on our end. There is a difference, however, between RadGridView and RadSparkLine. While RadGridView just displays the data, RadAreaSparkline needs to be configured to interpret that data in order to transfrom it to a graphical view. Besides providing ItemsSource, you need to set the XValuePath and YValuePath properties as described in this help topic.

    So, you can still use type independent ItemsSource (it just has to be IEnumerable) but you need to perfrom the extra step of teaching the control how to read that data using the properties mentioned above.

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top