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

GridDateTimeColumn with null binded values

Thread ID:

Created:

Updated:

Platform:

Replies:

122131 Feb 18,2016 03:43 PM UTC Feb 22,2016 12:59 PM UTC WPF 5
loading
Tags: SfDataGrid
Silvio
Asked On February 18, 2016 03:43 PM UTC

HI,

I have a GridDateTimeColumn column in a SFDataGrid whose binded to a property of type "DateTime?".
When the binded record has a value of null on that property, the cell displays the current date on itself instead of a blank cell as I espected.
Is there a way not to show the current date on that columns in such situations ?

In the same situation, supposing I'm able to fix the first problem, is there a way for the user to remove a date from a cell (that means to put to null the related binded property) ?

Jayapradha S [Syncfusion]
Replied On February 19, 2016 12:36 PM UTC

Hi Silvio,

Thank you for contacting Syncfusion Support.

You can display a null value on GridDateTimeColumn using NullText and NullValue properties. Also you can remove date from the cell by setting CanEdit as True as shown in the below code example,

Code Example:

  <Syncfusion:GridDateTimeColumn MappingName="JoiningDate" 

                                               CanEdit="True" 

                                               NullText="" 
                                               NullValue="{x:Null}" />


We have prepared a sample for your requirement and please find the sample from the following location,
Sample Link: http://www.syncfusion.com/downloads/support/forum/122131/ze/DateTime_NullValue1715036667

Regards,
Jayapradha
 

Silvio
Replied On February 19, 2016 02:39 PM UTC

I'm sorry but it seems your example doesn't work.

To further simplify the example I have changed the data initialization like this:


        private void PopulateCollection()
        {
            this.Clear();

          //  for (int i = 0; i < 700; i++)
            {
                BusinessObjects b = new BusinessObjects() { EmployeeName = "Mart", JoiningDate=new DateTime(2013,3,3), EmployeeAge = 45, EmployeeArea = "USA", EmployeeSalary = 33000, ExperienceInMonth = 10, EmployeeGender = "Male" , Rating = 2, CheckBoxValue = true};
                this.Add(b);
                b = new BusinessObjects() { EmployeeName = "Peter", EmployeeAge = 35, EmployeeArea = "UK", EmployeeSalary = 5678, ExperienceInMonth = 10, EmployeeGender = "Male", Rating = 1, CheckBoxValue = true };
                this.Add(b);
            }

        }


As you can see, the first record set a date equal to 3-3-2013, while the second record leaves the date to null.

But the datagrid, for the second record, shows the current date and not an empty cell.
In addition, when I try to remove the data, as soon as I finish editing, the current date again is placed on the cell instead of an empty string.
See the attached image.

Attachment: Cattura_92bace23.zip

Sivakumar R [Syncfusion]
Replied On February 19, 2016 02:59 PM UTC

Hi Silvio,

You can allow null values in GridDateTimeColumn by setting AllowNullValue property to true.

<Syncfusion:GridDateTimeColumn MappingName="JoiningDate"
                                CanEdit="True"  AllowNullValue="True"/>


documentation :
http://help.syncfusion.com/wpf/sfdatagrid/column-types?cs-save-lang=1&cs-lang=xaml#null-value-support-1

Thanks,
Sivakumar


Silvio
Replied On February 19, 2016 03:05 PM UTC

Hi Silvio,

You can allow null values in GridDateTimeColumn by setting AllowNullValue property to true.

<Syncfusion:GridDateTimeColumn MappingName="JoiningDate"
                                CanEdit="True"  AllowNullValue="True"/>


documentation :
http://help.syncfusion.com/wpf/sfdatagrid/column-types?cs-save-lang=1&cs-lang=xaml#null-value-support-1

Thanks,
Sivakumar


Thank you very much! Now it really works!

Ashwini Paranthaman [Syncfusion]
Replied On February 22, 2016 12:59 PM UTC

Hi Silvio,
Thank you for the update.
Please let us know if you need any other assistance.
Regards,
Ashwini P.

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

;