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

Dynamic grid with chart in column

5 Answers 83 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jfkrueger
Top achievements
Rank 1
jfkrueger asked on 20 Nov 2011, 04:13 AM
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!

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 21 Nov 2011, 08:49 AM
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 >>

0
jfkrueger
Top achievements
Rank 1
answered on 21 Nov 2011, 05:14 PM
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!
0
jfkrueger
Top achievements
Rank 1
answered on 22 Nov 2011, 07:42 PM
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!
0
jfkrueger
Top achievements
Rank 1
answered on 23 Nov 2011, 05:13 PM
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.
0
jfkrueger
Top achievements
Rank 1
answered on 23 Nov 2011, 06:30 PM
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!
Tags
GridView
Asked by
jfkrueger
Top achievements
Rank 1
Answers by
Vlad
Telerik team
jfkrueger
Top achievements
Rank 1
Share this question
or