I can't really find any examples where you guys use a datetime column in your grids. What i have is a grid that just has the following column binding:
if i use server binding, a sample result i get from the above is:
7/3/2012 5:48:01 PM
if i use ajax binding instead, the same value in the will read the following instead:
Tue Jul 03 2012 17:48:01 GMT-0700 (Pacific Daylight Time)
How do i format the data in the bound column? I want to use Ajax binding, but i want the value to display like the server binding above. I tried using the 'format' parameter for that bound column (and setting it to "d"), but that just make the display value for all rows in that column "d".
columns.Bound(o => o.FormattedDateCreated).Width(110);
7/3/2012 5:48:01 PM
if i use ajax binding instead, the same value in the will read the following instead:
Tue Jul 03 2012 17:48:01 GMT-0700 (Pacific Daylight Time)
How do i format the data in the bound column? I want to use Ajax binding, but i want the value to display like the server binding above. I tried using the 'format' parameter for that bound column (and setting it to "d"), but that just make the display value for all rows in that column "d".
6 Answers, 1 is accepted
0
Accepted
Gummy Coder
Top achievements
Rank 1
answered on 04 Jul 2012, 03:26 PM
Did you try ?
columns.Bound(p => p.FormattedDateCreated
).Format(
"{0:d}"
);
0
Phil
Top achievements
Rank 1
answered on 04 Jul 2012, 03:46 PM
That's it exactly! Thanks, just surprised it works different based on if you're doing things server-side vs. ajax.
0
Gummy Coder
Top achievements
Rank 1
answered on 05 Jul 2012, 02:36 AM
Yes, I see, so if you want the result of ajax binding with format "MM/dd/yyyy hh:mm:ss tt" as server binding you can use G instead of d
This is the code:
Hopes this help.
This is the code:
columns.Bound(p => p.FormattedDateCreated).Format("{0:G}");
Hopes this help.
0
Phil
Top achievements
Rank 1
answered on 05 Jul 2012, 06:55 PM
Thanks, i had noticed that. While this all fixes the problems if i have just a datetime, it unfortunately doesn't fix it if i have a nullable<datetime> value.
If this datetime value is null, then the server binding will just show that cell as blank, nothing in there (which is what i want).
In Ajax, this value will show as 'null'. Not sure how to change that one...
If this datetime value is null, then the server binding will just show that cell as blank, nothing in there (which is what i want).
In Ajax, this value will show as 'null'. Not sure how to change that one...
0
Gummy Coder
Top achievements
Rank 1
answered on 06 Jul 2012, 02:11 AM
You can use ClientTemplate to check data value of column it might be null.
I think all problems will be fixed in next release. Many things need to resolve in grid widget :) (compare to Telerik MVC Grid)
# if (value == 'null') {#
// to do something
# } #
I think all problems will be fixed in next release. Many things need to resolve in grid widget :) (compare to Telerik MVC Grid)
0
Phil
Top achievements
Rank 1
answered on 12 Jul 2012, 06:23 PM
just downloaded the 2012.2.710 today, and looks like this is still a problem. Looks like i'll have to implement your solution!