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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to load null value to the GridDateTimeColumn when AllowInlineEditing is set to true?

Platform: WinRT |
Control: SfDataGrid |
.NET Framework: 4.5

The SfDatePicker is loaded as UIElement of the GridDateTimeColumn in edit mode. By default, old value is replaced when you try to commit the blank value on editing and when the SfDatePicker.AllowInlineEditing property is enabled.

You can overcome this by deriving a new class from the GridCellDateTimeRenderer and overriding the OnEditElementLoaded virtual method. In this method, you can get the corresponding editor, SfDatePicker of the GridDateTimeColumn and you can explicitly set the SfDatePicker.Value as null in SfTextBoxExt.TextChanged event.

The SfTextBoxExt is loaded as editor of the SfDatePicker control.



public class GridCellDateTimeRendererExt : GridCellDateTimeRenderer


    SfDatePicker datepicker = null;

    protected override void OnEditElementLoaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)


        datepicker = (SfDatePicker)sender;

        //Gets the SfTextBoxExt editor loaded in the SfDatePicker

        SfTextBoxExt textBox = ((SfDatePicker)sender).FindDescendantByName("PART_TextBoxExt") as SfTextBoxExt;

       //TextChanged event of SfTextBoxExt is wired

        textBox.TextChanged += textBox_TextChanged;

        base.OnEditElementLoaded(sender, e);


           void textBox_TextChanged(object sender, Windows.UI.Xaml.Controls.TextChangedEventArgs e)


        var text = sender as SfTextBoxExt;

        if (text.Text == string.Empty && datepicker.AllowInlineEditing)


         //Sets null to value of SfDatePicker expilicitly

            datepicker.SetValue(SfDatePicker.ValueProperty, null);




In the above code example, FindDescendantByName is an extension helper method available in a attached sample.



Refer to the following code example to remove the default GridCellDateTimeRenderer and add the customized GridCellDateTimeRendererExt to the SfDataGrid.CellRenderer collection.


public MainPage()
    //Customized renderer is added to CellRenderers collection 
    this.grid.CellRenderers.Add("DateTime", new GridCellDateTimeRendererExt());

Sample Links:

WinRT: https://www.syncfusion.com/downloads/support/directtrac/141421/ze/WinRT2074283480

WP: https://www.syncfusion.com/downloads/support/directtrac/141421/ze/WindowsPhone-1688298690

You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile