Support of Google.Protobuf.WellKnownTypes.Timestamp class in Grid and Column

Hi,

I have a list of objects that have a member of type Google.Protobuf.WellKnownTypes.Timestamp and I want to display it in a Grid. Here is an excerpt of the class:

class VisitModel {
public Google.Protobuf.WellKnownTypes.Timestamp Executiondatetime;
}

I am trying to display it in a grid like this: (I have removed the HTML <> signs)

RadzenGridColumn TItem="VisitModel" Property="Executiondatetime" Title="Executed On" Width="10px"
Template Context="visit"
@if (visit.Executiondatetime == null)
new String("");
else
new String(String.Format("{0:MM/dd/yyyy h:mm:ss tt}", visit.Executiondatetime.ToDateTimeOffset().LocalDateTime));
Template
RadzenGridColumn

I understand that I must use a template but even if the Executiondatetime is not null, there is nothing displayed in the cell. It is important to mention that IF is not null and the template definition is like this below, it works fine...

@String.Format("{0:MM/dd/yyyy h:mm:ss tt}", visit.Executiondatetime .ToDateTimeOffset().LocalDateTime)

Any advice?

Thanks.

Well, after playing some more and looking at other example here, it seems that his code below works inside the Template definition

[at]if (visit.Executiondatetime == null)
[at]String.Empty
else
[at]String.Format("{0:MM/dd/yyyy h:mm:ss tt}", visit.Executiondatetime.ToDateTimeOffset().LocalDateTime)

It seams that for every C# line, we need to put the [at] symbol. How is that?

Could not use the real symbol since the editor was giving me an error...

Hi @slamarre,

This is just how Blazor works. You use @ to output properties and expressions. More info about the Razor syntax is available here.