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.
Unfortunately, activation email could not send to your email. Please try again.

Embedded grid into Cell

Thread ID:

Created:

Updated:

Platform:

Replies:

119319 Jun 4,2015 10:33 AM Jun 21,2015 12:16 PM WPF 9
loading
Tags: SfDataGrid
Tommie Chen
Asked On June 4, 2015 10:33 AM

I want to embed a grid into a column cell which based on different condition will show different grid. Is there a way to achieve this? I am using CellTemplateSelector datatemplate to do it, but when the datatemplate is SfDataGrid, it shows exception "source is not IEnumerable<>".

Thanks!



Muthukumar Kalyanasundaram [Syncfusion]
Replied On June 5, 2015 12:04 PM

Hi Tommie, 

Thank you for using Syncfusion products. 

We analyzed your query but we are unable to reproduce the reported issue at our end. We have prepared simple sample based on your requirement. Please review the implementation in this sample.  If you are still seeing the same issue, please modify this sample to reproduce the issue and send the modified sample back to us. This will help us to proceed further. 

Sample: http://www.syncfusion.com/downloads/support/forum/119319/ze/CellTemplateSelector_SfDataGrid580013410 

Please let us know if you have any concerns. 

Regards,

Muthukumar K


Tommie Chen
Replied On June 9, 2015 04:05 PM

 

Hi Muthukumar ,

Thank you for your response. I was using a static CollectionViewSource for cell template, and it fails. After I changed as your sample data structure, it works okay. I have another question:

If CellTemplateSelector and EditTemplateSelector use different template, but it only shows the template from CellTemplateSelector. I also try to modify directly of your sample, it also only display the template from CellTemplateSelector. Even when I change the cell template to a simple template which only holds one textbox or textblock.

Thank you


Ashok N [Syncfusion]
Replied On June 11, 2015 11:29 PM

Hi Tommie,

Thank you for your update.

In SfDataGrid we have support for CellTemplateSelector and EditTemplateSelector to GridTemplateColumn. You can achieve your requirement by using CellTemplateSelector itself. For your reference we provided a sample with both CellTemplateSelector and EditTemplateSelector in our previous update. EditTemplateSelector will be loaded when we edit the GridCell.

Please refer to the following UG link to find more details on the GridTemplateColumn,

UG link: http://help.syncfusion.com/ug/wpf/index.html#!Documents/gridtemplatecolumn.htm

Please let us know if you require further assistance on this.

Thanks,
Ashok


Tommie Chen
Replied On June 12, 2015 12:23 PM

Hi,

I know the document link. I have tried use different EditTemplate in the sample your provide, for example below, and the grid show both Celltemplate and EditTemplate ,and overlap them together. Could you please take a look at it?

  <!-- CellTemplate --> 
        <DataTemplate x:Key="Branch10">
            <Grid>
                <Syncfusion:SfDataGrid x:Name="sfd" AutoGenerateColumns="False" 
                               ItemsSource="{Binding Path=ProductsDetails1}" Background="LightGreen"
                                       ColumnSizer="Auto" RowHeight="20">
                    <Syncfusion:SfDataGrid.Columns>
                        <Syncfusion:GridTextColumn MappingName="ProductId1" />
                        <Syncfusion:GridTextColumn MappingName="ProductName1" />
                    </Syncfusion:SfDataGrid.Columns>
                </Syncfusion:SfDataGrid>
                <TextBlock Text="{Binding ProductName}"/>
            </Grid>
        </DataTemplate>
        <!-- EditTemplate -->
        <DataTemplate x:Key="Branch1">
            <Grid>
                <TextBox Text="{Binding ProductName}"/>
                </Grid>            
        </DataTemplate>


Muthukumar Kalyanasundaram [Syncfusion]
Replied On June 15, 2015 09:58 AM

Hi Tommie,   


We are not able to understand your inquiry. When you set both CellTemplate and EditTemplate, CellTempalte will load for display mode and EditTemplate will load when you are editing the cell. Could you therefore clarify this part of your question:  "Celltemplate and EditTemplate are overlap them together"? Once we understand your requirement, we will be able to provide a solution.


Please review my response.  

Regards,

Muthukumar K


Tommie Chen
Replied On June 16, 2015 10:33 AM

Hi,
I have tried to modify your sample, and couldn't make it work to show different Cell or Edit template. here is the sample. please have a look. 
Thanks again,


Attachment: CellTemplateSelector_SfDataGrid_e0cfa3f.zip

Muthukumar Kalyanasundaram [Syncfusion]
Replied On June 17, 2015 01:59 PM

Hi Tommie, 

Thanks for the update. 

In the sample you have provided TextBlock overlapped with Grid and now we have modified in the below sample, 

Sample: http://www.syncfusion.com/downloads/support/forum/119319/ze/CellTemplateSelector_SfDataGrid-864330432 

Please refer the attached screenshot.

ScreenShot: http://www.syncfusion.com/downloads/support/forum/119319/ze/ScreenSot1159599775 

Could you clarify your requirement based on this sample and update us? This will help us provide a solution. 

Regards,

Muthukumar K


Tommie Chen
Replied On June 18, 2015 04:37 PM

Hi,
Please see my intended changes below,   I use TextBlock in cell template "Branch10",  and TextBox  as in Edit template "Branch1". But when I double click the cell(want to the edition), it couldn't show TextBox  as in Edit template "Branch1".  Same for edit template  "Branch2", which counld't be shown. "Branch2" is editable, and  have different background color than "Branch1".

Let me know if this is not clear.


   <!-- CellTemplate --> 
        <DataTemplate x:Key="Branch10">
            <Grid VerticalAlignment="Center">                
                <TextBlock Text="{Binding ProductName}" />
            </Grid>
        </DataTemplate>
        <!-- EditTemplate -->
        <DataTemplate x:Key="Branch1">
            <Grid>
                <TextBox Text="{Binding ProductName}"/>
             </Grid>            
        </DataTemplate>
        <DataTemplate x:Key="Branch20">
            <Grid>
                <Syncfusion:SfDataGrid x:Name="sfd" AutoGenerateColumns="False" 
                               ItemsSource="{Binding Path=ProductsDetails1}" Background="LightPink"
                               ColumnSizer="Auto" RowHeight="20">
                    <Syncfusion:SfDataGrid.Columns>
                        <Syncfusion:GridTextColumn MappingName="CustomerId1"/>
                        <Syncfusion:GridTextColumn MappingName="ShipmentDetails1"/>
                    </Syncfusion:SfDataGrid.Columns>
                </Syncfusion:SfDataGrid>
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="Branch2">
            <Grid>
                <Syncfusion:SfDataGrid x:Name="sfd" AutoGenerateColumns="False" 
                               ItemsSource="{Binding Path=ProductsDetails1}" Background="Pink"
                               AllowEditing="True"
                               ColumnSizer="Auto" RowHeight="20">
                    <Syncfusion:SfDataGrid.Columns>
                        <Syncfusion:GridTextColumn MappingName="CustomerId1"/>
                        <Syncfusion:GridTextColumn MappingName="ShipmentDetails1"/>
                    </Syncfusion:SfDataGrid.Columns>
                </Syncfusion:SfDataGrid>
            </Grid>
        </DataTemplate>



Muthukumar Kalyanasundaram [Syncfusion]
Replied On June 21, 2015 12:16 PM

Hi Tommie, 

We analyzed your query. Based on your code, seems you are loading one SfDataGrid in CellTemplate and also in EditTemplate of GridTemplateColumn. So when you double click on the DataGrid loading inside template, it will load EditTemplate (which also has DataGrid). Please refer to the screenshot(image1). 

Now if you double click DataGrid inside Cell (Loaded from EditTemplate), TextBox will load for the DataGrid inside DataTemplate. Please refer to the screenshot(image2). This is the behavior of DataGrid.


Screenshothttp://www.syncfusion.com/downloads/support/forum/119319/ze/Screenshot-408070851 

Samplehttp://www.syncfusion.com/downloads/support/forum/119319/ze/CellTemplateSelector_SfDataGrid-399297813  

Do you want to edit the DataGrid inside Main DataGrid Cell?  If so, it is not possible to edit in single click. But you can do this by double click by setting EditTrigger property to MainDataGrid and also by setting DataGrid inside Template. 

Please let us know if we have not addressed your requirement.   

Regards,

Muthukumar K


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.

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.

;