Dynamic grid with chart in column

6 posts, 0 answers
  1. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 19 Nov 2011 Link to this post

    Is there any way to create a grid similar to the attached? With the kicker being that I won't know the years at design time. Without pivot functionality i'm kind of doubting it...

    Thanks!
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 21 Nov 2011 Link to this post

    Hi,

     There will be no problem to use dynamic objects to achieve your goal in this case. You can check my blog post for more info about binding to dynamics.

    Regards,
    Vlad
    the Telerik team

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

  3. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 21 Nov 2011 Link to this post

    Hey Vlad thanks for the response! That is indeed a great post, but being new to Silverlight I am not really getting how it would help me. It looks like in your example you know the column names ahead of time. In my case I will not, it will be a range of years that will be selected by the user and can be changed at any time, so I need the functionality to pivot my data and create the columns dynamically. On top of that, I don't see how it helps me to generate the chart inside of the trend column. Is there a way i could get an example specific to my scenario or more guidance?

    Thanks!
  4. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 22 Nov 2011 Link to this post

    Correction: I see how the columns are auto-generated in the example but that isn't what I'm getting hung up on, I'm hung up on generating the chart dynamically. Thanks!
  5. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 23 Nov 2011 Link to this post

    So what i'm thinking is that I can basically add all of the grid columns dynamically. I'm pretty sure I can figure that out which takes care of the lack of pivot functionality but I am just not getting how I would dynamically create the trend charts column. I would imagine I would be drawing rectangles but being a newbie I have no idea how to tackle this when having to actually create the grid columns dynamically in the code.
  6. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 23 Nov 2011 Link to this post

    So here is what I have so far, hopefully I am going down the right path...

    Gridview with no columns defined at design-time:

    <telerik:RadGridView x:Name="RadGridViewTrends" 
                            AutoGenerateColumns="false" ShowGroupPanel="False" 
                            FontSize="9"
                            IsFilteringAllowed="False" ShowColumnFooters="False"
                            Margin="5,10,0,0"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            Grid.Row="0"
                            VerticalAlignment="Top" />

    Code to create the columns:

    Public Sub CreateColumns()
      
        RadGridViewTrends.Columns.Add(CreateColumn(GetType(String), "Category", "Category"))
        RadGridViewTrends.Columns.Add(CreateColumn(GetType(Decimal), "year1", "2005"))
        RadGridViewTrends.Columns.Add(CreateColumn(GetType(Decimal), "year2", "2006"))
        RadGridViewTrends.Columns.Add(CreateColumn(GetType(Decimal), "year3", "2007"))
        RadGridViewTrends.Columns.Add(CreateColumn(GetType(Decimal), "year4", "2008"))
        RadGridViewTrends.Columns.Add(CreateColumn(GetType(Decimal), "year5", "2009"))
        RadGridViewTrends.Columns.Add(CreateColumn(GetType(Decimal), "year6", "2010"))
        RadGridViewTrends.Columns.Add(CreateColumn(GetType(Decimal), "year7", "2011"))
      
    End Sub
      
    Private Function CreateColumn(ByVal columnType As Type,
        ByVal uniqueName As String, _
        ByVal headerText As String) As GridViewDataColumn
      
        Dim dataGridColumn As New GridViewDataColumn()
        Dim lBinding As New Binding(uniqueName)
      
        lBinding.Mode = BindingMode.OneWay 
      
        dataGridColumn.DataType = columnType
        dataGridColumn.UniqueName = uniqueName
        dataGridColumn.Header = headerText
        dataGridColumn.DataMemberBinding = lBinding
      
        Return dataGridColumn
      
    End Function

    So basically I am just missing the last "Trend" column. I am guessing I will need to generate a template column of some sort and then somehow get into the template and draw some rectangles. THIS is where I am getting hung up. Does it look like I am going in the right direction and if so can anyone provide guidance on creating the "trend" charts in the last column?

    Thank you!
Back to Top