Default to DateTime.Now for new record in Grid

How would I set the default date/time to Now when I add a new record in a Grid with a DateTimePicker control in the EditTemplate.

        <GridColumn Field=@nameof(TimeSheets.DateStart) HeaderText="Start" Width="70" CustomFormat="@(new { type ="date", format="MM/dd/yyyy" })"                     TextAlign="TextAlign.Right" Type="ColumnType.Date" ValidationRules="@(new ValidationRules{ Required = true })">
            <EditTemplate>
                <SfDateTimePicker @bind-Value="@((context as TimeSheets).DateStart)" Max="DateTime.Now" Min="@StartDate" ShowClearButton="true"                          StrictMode="true"></SfDateTimePicker>
            </EditTemplate>
            <Template>
                @{
                    var t = (context as TimeSheets);
                    <span>@t.DateStart.ToString("MM/dd/yyyy HH:mm")</span>
                }
            </Template>
        </GridColumn>

I tried setting the Column Value to DateTime.Now in the OnActionComplete by using:

public void OnComplete(ActionEventArgs<TimeSheets> Args)
......
            case Syncfusion.Blazor.Grids.Action.Add:
                ts.LastUpdated = DateTime.Now;
                ts.EmpId = Guid.NewGuid();
                ts.DateStart = DateTime.Now;
                break;

But that doesn't work.
Thanks,
Mike

1 Reply

SP Sureshkumar P Syncfusion Team October 5, 2020 10:55 AM UTC

Hi Michael,  
 
Greetings from Syncfusion support.   
 
We confirmed the reported issue " Predefined value is not set to the control when Max property and Value are same in strict mode" as a bug in our end and the fix will be available in one of the upcoming patch release which is expected to be rolled out at October 7th, 2020 . You can track the status of the bug in the below feedback link from below.    
 
 
We appreciate your patience until then.  
 
Regards,  
Sureshkumar P 


Loader.
Up arrow icon