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

Is one cell can be binded to multiple property?

3 Answers 177 Views
GridView
This is a migrated thread and some comments may be shown as answers.
PC
Top achievements
Rank 1
PC asked on 12 Aug 2014, 03:19 AM
Hi,
I have a view that one cell can have a multiple content from two different property of the data model, I try some of the sample from documentation and have no success, any hint or guide to get this done
thank you.

my code snippet 

<telerik:GridViewDataColumn
Header="Case Type"
DataMemberBinding="{Binding CaseDetails}"
Style="{DynamicResource ColumnTextCenter}">
                    <telerik:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <TextBlock Text="{Binding CaseDetails[0].Type}"/>
                                <TextBlock Text="{Binding CaseDetails[0].LandArea} Grid.Row="1 FontStyle="Italic"/>
                            </Grid>                           
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate>                   
                </telerik:GridViewDataColumn>

3 Answers, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 12 Aug 2014, 11:26 AM
Hello,

In general, it is possible to have a layout control as a CellEditTemplate, which contains multiple controls bound to different properties from your ViewModel. I attached a sample project that demonstrates how you can do just that. For the purpose of this example, I have edited the CellEditTemplate template of the first column in a way that it contains two TextBox controls. Which are bound to the Name and StadiumCapacity properties of the Club business object. However, I am not entirely sure what you need to achieve and how your ViewModel and business object are built.

Could you please provide us with more details about your case and some pictures on how you envision the end result should look like? 


Regards,
Boris Penev
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
PC
Top achievements
Rank 1
answered on 12 Aug 2014, 03:00 PM
I've check your sample, but it is not like a view I expect.
My ViewModel has a collection of record and for each item I want to combine two properties value to be shown in one cell, I've attach a sample diagram to illustrate the view I want.
0
PC
Top achievements
Rank 1
answered on 13 Aug 2014, 01:38 AM
Never mind I already found the solution for that I supposed to be using that CellTemplate insted of CellEditTemplate.
<telerik:GridViewDataColumn Header="Case Type" DataMemberBinding="{Binding CaseDetails}" Style="{DynamicResource ColumnTextCenter}">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <TextBlock Text="{Binding CaseDetails[0].Type}"/>
                                <TextBlock Text="{Binding CaseDetails[0].LandArea} Grid.Row="1 FontStyle="Italic"/>
                            </Grid>                          
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>                  
                </telerik:GridViewDataColumn>
Tags
GridView
Asked by
PC
Top achievements
Rank 1
Answers by
Boris
Telerik team
PC
Top achievements
Rank 1
Share this question
or