difference between CellStyle-Template and CellTemplate

4 posts, 1 answers
  1. Vit100
    Vit100 avatar
    66 posts
    Member since:
    Oct 2012

    Posted 09 Jul 2012 Link to this post

    Hey guys,
    Could u pls explain me difference between this code
    <telerik:RadGridView AutoGenerateColumns="False" ItemsSource="{Binding}">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn >
      
                       <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <Button  Content="{Binding}"/>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>
                     
                 </telerik:RadGridView.Columns>
            </telerik:RadGridView>


    and this one?
    <telerik:RadGridView AutoGenerateColumns="False" ItemsSource="{Binding}">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn >
     
                <telerik:GridViewColumn.CellStyle>
                    <Style TargetType="telerik:GridViewCell">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Button Content="{Binding}"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                               
                    </Style>
                </telerik:GridViewColumn.CellStyle>
                 
            </telerik:GridViewDataColumn>
             
     
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>


    I think it is same result, right? In first case we define cell via style - template, in second case via CellStyle...
  2. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Jul 2012 Link to this post

    Hello,

     Both techniques and results actually are completely different. 

    - In the first snippet you are using DataTemplate which RadGridView will load runtime in a special part of the grid cell. In this case the template will not override anything inside the cell - will just change the "value" part of the cell.

    - In the second snippet you are using ControlTemplate to override the entire grid cell template and place your own.

    Greetings,
    Vlad
    the Telerik team

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

  3. DevCraft banner
  4. Vit100
    Vit100 avatar
    66 posts
    Member since:
    Oct 2012

    Posted 10 Jul 2012 Link to this post

    right, this is what I think.
    But visual result is same (or similar).
    What is purpose of CellTemplate (with DataTemplate inside) if it is possible achive same result with Styles (and Template/ControlTemplate inside)?
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Jul 2012 Link to this post

    Hi,

     Please check once again my previous response for more info about what part of the cell will be changed when you modify these templates. 

    Regards,
    Vlad
    the Telerik team

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

Back to Top