Grid.Blazor icon indicating copy to clipboard operation
Grid.Blazor copied to clipboard

GetFormatedDateTime time type issue

Open faina09 opened this issue 3 years ago • 1 comments

I use GridBlazor 2.1.14 and get an issue from GetFormatedDateTime because it try to convert a value that is already of type System.TimeSpan:

else if (type == "time")
	textValue = string.Format("{0:HH:mm}", value);

The field is a time(3) in SqlServer, defined in the Model class as

[GridColumn(FilterEnabled = true, SortEnabled = true, Title = "TimeSpan")]
public TimeSpan? TimeSpan { get; set; }

and in ColumnCollection as c.Add(o => o.TimeSpan).Titled("TimeSpan");

the UI presents a nice input: image

but I needed to modify the code this way to have it working:

else if (type == "time")
	textValue = value.ToString();

faina09 avatar May 14 '21 16:05 faina09

This is really a blocking issue for me, I cannot use a TimeSpan column because I get a "string format exception" when I try to view or edit a grid line containing this type. Currently I must use a custom generated package :-( Is there a way to override GridColumnBase.cs public string GetFormatedDateTime(object value, string type)?

faina09 avatar Sep 15 '21 10:09 faina09