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

[Solved] Column Collections

1 Answer 156 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lilia
Top achievements
Rank 1
Lilia asked on 05 Aug 2011, 07:56 AM
Hello Telerik team,

I have dynamic number of columns for my GridView, i.e. I don't know how many columns I will have in my GridView, but I know that I'll have 5 of them for sure. I don't wanna use AutoGenerateColumns, so I can define my columns. For the dynamic columns I have a different data source. Is there a property, for example GridViewDataColumnCollection to bind my dynamic columns or I have to create the columns in code behind?

<telerik:RadGridView.Columns>
      <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Name}"
                        Header="Name">
             <telerik:GridViewDataColumn.Footer>
                     <TextBlock Text="Total"  FontWeight="Bold" />
              </telerik:GridViewDataColumn.Footer>
      </telerik:GridViewDataColumn>
      <telerik:GridViewDataColumnCollection  DataMemberBinding="{Binding Path=DynamicColumnsList}>
      </telerik:GridViewDataColumnCollection>
</telerik:RadGridView.Columns>


1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 05 Aug 2011, 09:17 AM
Hi Lilia,

 You can bind the grid columns to a view model property using attached behaviors. You can check the attached example application for more info. 

Kind regards,
Vlad
the Telerik team

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

Tags
GridView
Asked by
Lilia
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or