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