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.
Syncfusion Feedback

Serialization of GridTemplateColumn

Thread ID:

Created:

Updated:

Platform:

Replies:

123323 Mar 8,2016 11:26 AM UTC Mar 11,2016 04:23 AM UTC WPF 3
loading
Tags: SfDataGrid
Kurt Zimmermann
Asked On March 8, 2016 11:26 AM UTC

Hi,
I have added a GridTemplateColumn to my DataGrid. Inside the CellTemplate are two Buttons. After serialization and deserialization the Buttons are gone.
I have changed your Serialization sample to demonstrate the Problem - I have added this column:

<syncfusion:GridTemplateColumn HeaderText="Test" MappingName="SupplierID">

<syncfusion:GridTemplateColumn.CellTemplate>

<DataTemplate>

<Button Content="{Binding SupplierID}" />

</DataTemplate>

</syncfusion:GridTemplateColumn.CellTemplate>

</syncfusion:GridTemplateColumn>


After clicking Serialize and then Deserialize the Buttons are gone.
Is there a way to use der GridTemplateColumn with serialization?

Thanks

Kurt

Sowndaiyan Paulpandi [Syncfusion]
Replied On March 9, 2016 01:12 PM UTC

Hi Kurt,

Thanks for contacting Syncfusion Support.

We regret to inform you that in SfDataGrid it is not possible to Serialize GridTemplateColumn. However you can achieve your requirement by manually adding the CellTemplate to the GridTemplateColumn while performing the Deserialization like the below code example. We have prepared a work around sample as per your requirement and you can  download the same from the below location,

C#


private
static void OnExecuteDeserialize(object sender, ExecutedRoutedEventArgs args)

        {

            var dataGrid = args.Source as SfDataGrid;

            if (dataGrid == null) return;

            var options = args.Parameter as DeserializationOptions;

            try

            {

                using (var file = File.Open("DataGrid.xml", FileMode.Open))

                {

                    dataGrid.Deserialize(file, options);


                    var col = dataGrid.Columns.FirstOrDefault(column => column.MappingName == "SupplierID");


                    col.CellTemplate = App.Current.Resources["TemplateColumn"] as DataTemplate;

                  

                }

            }

            catch (Exception)

            {


            }

        }




Sample :  http://www.syncfusion.com/downloads/support/forum/123323/ze/SerializationDemo-380074400



Regards,

Sowndaiyan


Kurt Zimmermann
Replied On March 10, 2016 08:11 PM UTC

Thank you for the fast Response - this works perfect!

Regards,

Kurt

Srinivasan Vasu [Syncfusion]
Replied On March 11, 2016 04:23 AM UTC

Hi Kurt,

Thanks for the update.


Please let us know if you need further assistance.
Regards,
Srinivasan

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

;