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

How to bind data to dynamic columns?

4 Answers 171 Views
GridView
This is a migrated thread and some comments may be shown as answers.
mao ruixian
Top achievements
Rank 1
mao ruixian asked on 18 May 2010, 09:40 AM
My data is:
           studentid      cid                       cname         place
row1    01                01                        english        shanghai
row2    01                02                        math            tokyo
row3    02                01                        english        shanghai

I want to show:

studentid         english                 math
01                   shanghai                tokyo
02                   shanghai

And I want to show the columns "english" and "math" according to the data in database.
if there is no math class. Just show 

studentid         english                 
01                   shanghai                
02                   shanghai

Could you please tell me how to do that by telerik gridview, thanks.


Thank you so much for your help.

4 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 18 May 2010, 10:17 AM
Hi mao ruixian,

Please look at the following blog posts for possible solutions:

Hope this helps,
Stefan Dobrev
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
mao ruixian
Top achievements
Rank 1
answered on 18 May 2010, 10:52 AM
Thank you for your answer.
Does that mean I have to create a class dynamically and bind the dynamic class to the grid view?
0
Stefan Dobrev
Telerik team
answered on 19 May 2010, 09:54 AM
Hello mao ruixian,

You can create your own class that the grid will be bound to, without generating a dynamic class. It will have all the required properties that you need to display. You can check MicroModels for Silverlight that can simplify this task.

Best wishes,
Stefan Dobrev
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
feng
Top achievements
Rank 1
answered on 24 Sep 2011, 04:27 PM
hi
i have the same problem.....now i take the micromodels to bind radgridview e.g 
 <Grid x:Name="LayoutRoot" DataContext="{Binding Object}">
<telerik:RadGridView  AutoGenerateColumns="False" x:Name="HierarchicalGridView" ItemsSource="{Binding Path=LineItems}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Id, Mode=TwoWay}"  Header="Id" >
                    </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Name}"  Header="Name">
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

why the column is empty.......
Tags
GridView
Asked by
mao ruixian
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
mao ruixian
Top achievements
Rank 1
feng
Top achievements
Rank 1
Share this question
or