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

difference between CellStyle-Template and CellTemplate

3 Answers 218 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vit100
Top achievements
Rank 1
Vit100 asked on 09 Jul 2012, 07:18 PM
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...

3 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 10 Jul 2012, 05:21 AM
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 >>

0
Vit100
Top achievements
Rank 1
answered on 10 Jul 2012, 01:18 PM
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)?
0
Vlad
Telerik team
answered on 10 Jul 2012, 01:21 PM
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 >>

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