how can I hide the default date value "01.01.1901" ?

How can I hide the default date value "01.01.1901" ?


6 Replies

DR Dolmatov Roman June 28, 2021 09:43 AM UTC

I use like this: <e-grid-column field="PickUpDate" headerText="Project" customFormat="@(new { type="date", format="dd.MM.yyyy" })" textAlign="Right"></e-grid-column>



DR Dolmatov Roman June 28, 2021 09:46 AM UTC

88881.jpgI need to hide "01.01.1901"



PM Ponmani Murugaiyan Syncfusion Team June 28, 2021 12:00 PM UTC

Hi Dolmatov, 

Thanks for contacting Syncfusion support. 

You have provided the value property type as DateTime. So that the DateTimePicker component rendered with default date (01.01.1901). We suggest you to provide the type as DateTime nullable instead of DateTime as like below code to achieve your requirement. 

public class DateTimeValue 
    { 
          public DateTime? value { get; set; } 
    } 

Regards, 
Ponmani M 



DR Dolmatov Roman June 28, 2021 01:47 PM UTC

It did not help me   I almost have 

"01.01.1901" in default ((((



DR Dolmatov Roman June 28, 2021 01:49 PM UTC

I need to have empty  "         "    )), use default...



TS Thiyagu Subramani Syncfusion Team June 30, 2021 03:17 AM UTC

Hi Dolmatov, 

Thanks for your update. 

We can achieve your requirement by using below code in rowDataBound event. Because rowDataBound event triggered every time a request is made to access row information, element, or data. This will be triggered before the row element is appended to the Grid element. 

We have separated required Date column td cell by adding additional class like ‘e-custom’ using customAttribute property. 

 
<e-grid-column field="OrderDate" headerText="Project" customAttributes=@(new { @class="e-custom" })  customFormat="@(new { type="date", format="dd.MM.yyyy" })" textAlign="Right"></e-grid-column> 
 
function rowDataBound(args) { 
        if (args.data.OrderDate.toLocaleDateString() === '1/1/1901') { 
            args.data.OrderDate = null;  // define null or empty 
            args.row.getElementsByClassName('e-custom')[0].innerText = '';  // likewise we can define the innerText value as empty for specific cells 
        } 
    } 


 


 

Please get back to us, if you need any further assistance. 

Regards, 
Thiyagu S 


Loader.
Up arrow icon