This question is locked. New answers and comments are not allowed.
This is what I originally had, but I want to conditionally handle the formatting.
If DateTime == DateTime.Min then I want to show an empty value rather than DateTime.Min...
So...
I have created and Extension Method to handle my DateTime formatting...
How can I pass in the value correctly to the method for the grid...
Example:
On one of my columns I have the Telerik Format method where I want to call my extension method to do the formatting, I thought this might work but instead its passing in the literal "{0}"
How can I pass in the correct value ?
.Format("{0:MM/dd/yyyy}")
If DateTime == DateTime.Min then I want to show an empty value rather than DateTime.Min...
So...
I have created and Extension Method to handle my DateTime formatting...
How can I pass in the value correctly to the method for the grid...
Example:
On one of my columns I have the Telerik Format method where I want to call my extension method to do the formatting, I thought this might work but instead its passing in the literal "{0}"
.Format(Html.FormatDateTime("{0}"))
How can I pass in the correct value ?
6 Answers, 1 is accepted
0
Hello Gabe,
Regards,
Atanas Korchev
the Telerik team
The format accepts only strings. If you have a custom formatting method you must set the Template for your column:
column.Bound(d => d.Date).Template((d) =>
{
%>
<%= Html.FormatDateTime(d.Date) %>
});
Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Gabe
Top achievements
Rank 1
answered on 28 Apr 2011, 03:42 PM
I am using Client Side Binding, how can I do this using Client Side Binding?
0
Hi Gabe,
Atanas Korchev
the Telerik team
You cannot do this via client-side binding because there is no way to use server side method in the browser. You have to create a client-side template which will format the date properly or just use a custom date format for your column.
Regards,Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Gabe
Top achievements
Rank 1
answered on 28 Apr 2011, 03:57 PM
So the clientside template would have to use some script to format the date, I tried that... But didn't pan out...
Here's what I tried..
The value ends up blank in the cell...
Here's what I tried..
.ClientTemplate("<script>formatDateTime('<#= EffectiveDate #>')</script>")
The value ends up blank in the cell...
0
Gabe
Top achievements
Rank 1
answered on 28 Apr 2011, 04:28 PM
I got it to work like this:
Is this a good approach?
.ClientTemplate("<#= formatDateTime(EffectiveDate) #>")
Is this a good approach?
0
Accepted
Hi Gabe,
Atanas Korchev
the Telerik team
Yes, this is the best approach.
Regards,Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items