This is a migrated thread and some comments may be shown as answers.

Format not applying to column

1 Answer 183 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ricky
Top achievements
Rank 1
Ricky asked on 26 Jun 2018, 05:47 PM

I have the following code:

.Columns(columns => {
    columns.Bound(c => c.CreatedDateTime).Width(180).Format("{0: dd MMM yyyy HH.mm}").Title("Date");
    columns.Bound(c => c.Action.ActionDateTime).Format("{0: dd MMM yyyy HH.mm}").Width(280).Title("Action Date");
})

 

Both columns show the date and the JSON seems to have both dates correctly passed through.

However the 1st one displays the date correctly and the second one does not.

1st DateTime: 01 May 2018 08.45

2nd DateTime: 2018-06-01T13:01:05

 

Further details:

The data is obtained from two joined tables using EF Core.

I had to add the Json option Referenceloophandling.ignore to get the data to pass through, though I doubt this has anything to do with the problem as the Telerik Grid obviously has the correct data.

 

Can someone please help me format this date correctly.

 

Thanks,

Ricky

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 29 Jun 2018, 09:37 AM
Hello Ricky,

The issue is that the ActionDateTime is nested in another object and the Grid is designed to work with flat data. If you move the ActionDateTime property outside from the Action object and place it directly in the Grid model, the issue will be resolved.

Another option would be to use ClientTemplate and manually format the value:
ClientTemplate("#= myFuncForFormat(Action.ActionDateTime) #")
...
 
<script>
  function myFuncForFOrmat(value){
      ...
      return formatedValue;
  }

I will also forward this to our developers team, so they could determine whether or not we can apply internal solution for such cases.


Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Ricky
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or