We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

It is possible to apply a row datatemplate to SfDataGrid ?

Thread ID:

Created:

Updated:

Platform:

Replies:

132433 Sep 1,2017 07:13 AM UTC Sep 25,2017 06:55 AM UTC WPF 4
loading
Tags: SfDataGrid
Silvio
Asked On September 1, 2017 07:13 AM UTC

Hi,

I'd like to use SfDataGrid to show a readonly list of records where the user can sort, filter and group records, but I'd like to implement my own datatemplate to show each record on each row of the datagrid.
I'm refererring to something similar to this:

https://wpftutorial.net/ListBoxDataTemplate.html

Is it possible to obtain such a functionality using SfDatagrid ?

Thank you,

Silvio Scattaglia



Steve Schmutzler
Replied On September 3, 2017 09:22 AM UTC

Hi Silvio,

well I think it is possible by using the GridTemplateColumn:

<Syncfusion:SfDataGrid x:Name="customersSfDataGrid" Margin="10" AutoGenerateColumns="False" RowHeight="80" AllowResizingColumns="True">
            <Syncfusion:SfDataGrid.Columns>
                <Syncfusion:GridImageColumn HeaderText="Bild" MappingName="Image" AllowSorting="False" />
                <Syncfusion:GridTemplateColumn HeaderText="Details" AllowSorting="False" >
                    <Syncfusion:GridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Abteilung}" FontWeight="Bold" FontSize="16" />
                                <TextBlock Text="{Binding Vorname}" FontStyle="Italic" FontSize="14" />
                                <TextBlock Text="{Binding Phone}" />
                            </StackPanel>
                        </DataTemplate>
                    </Syncfusion:GridTemplateColumn.CellTemplate>
                </Syncfusion:GridTemplateColumn>
            </Syncfusion:SfDataGrid.Columns>
        </Syncfusion:SfDataGrid>

Looks like this:


Best regards

Steve


Muthukumar Kalyanasundaram [Syncfusion]
Replied On September 4, 2017 07:12 PM UTC

Hi Steve, 

As per your update, you can use GridTemplateColumn to achieve your requirement. But in your code you didn’t set the MappingName for GridTemplateColumn. You should set the MappingName when defining columns because we did all operations (Sorting, Filtering, Grouping etc..) based on the MappingName only. 
<Syncfusion:GridTemplateColumn HeaderText="Details" AllowSorting="False" MappingName="Details" > 
      <Syncfusion:GridTemplateColumn.CellTemplate> 
              <DataTemplate> 
                    <StackPanel Orientation="Vertical"> 
                       <TextBlock Text="{Binding Abteilung}" FontWeight="Bold" FontSize="16" /> 
                       <TextBlock Text="{Binding Vorname}" FontStyle="Italic" FontSize="14" /> 
                       <TextBlock Text="{Binding Phone}" /> 
                    </StackPanel> 
              </DataTemplate> 
      </Syncfusion:GridTemplateColumn.CellTemplate> 
</Syncfusion:GridTemplateColumn> 
 
Please let us know if you have further assistance on this. 

Regards, 
Jai Ganesh S 


Silvio
Replied On September 23, 2017 10:12 AM UTC

Thank you guys for your help!


Silvio


Gnanasownthari Thirugnanam [Syncfusion]
Replied On September 25, 2017 06:55 AM UTC

Hi Silvio, 

Thank you for your update. 

Please let us know if you have any further assistance on this. 

Regards, 
Gnanasownthari T. 



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;