Is one cell can be binded to multiple property?

4 posts, 0 answers
  1. PC
    PC avatar
    6 posts
    Member since:
    Apr 2011

    Posted 11 Aug 2014 Link to this post

    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>
  2. Boris
    Admin
    Boris avatar
    276 posts

    Posted 12 Aug 2014 Link to this post

    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.
     
  3. PC
    PC avatar
    6 posts
    Member since:
    Apr 2011

    Posted 12 Aug 2014 in reply to Boris Link to this post

    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.
  4. PC
    PC avatar
    6 posts
    Member since:
    Apr 2011

    Posted 12 Aug 2014 Link to this post

    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>
Back to Top