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

[Solved] Format grid

5 Answers 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Quang
Top achievements
Rank 1
Quang asked on 25 Apr 2011, 02:07 PM
hi all!
how to add serial number for grid?
how to format for datetime field on ClientTemplate. Ex: <#= datefilte#> to output text 'yyyy-MM-dd'?

thanks for supports.

5 Answers, 1 is accepted

Sort by
0
Quang
Top achievements
Rank 1
answered on 25 Apr 2011, 07:46 PM
Hi
please help me.
'reqstDT' is datetime type. now i want to format it output "yyyy-MM-dd". but i don't know anyway to do that.
<#=reqstDT#>


thanks so much.
columns.Bound(o => o.empCode).ClientTemplate("<a onclick=\"WM_Script.onEditPOERegist('<#=empCode#>','<#=reqstDT#>','<#=ctfFlag#>');\"><button>Edit</button><a>").Encoded(false).Title("").Width(40);
0
Demon
Top achievements
Rank 1
answered on 26 Apr 2011, 07:34 AM
The columns have a Format() method. Check out the demos source:

http://demos.telerik.com/aspnet-mvc/grid
0
Quang
Top achievements
Rank 1
answered on 26 Apr 2011, 07:48 AM
thanks for support.

but i use ('<#=empCode#>','<#=reqstDT#>','<#=ctfFlag#>'); 3 field. i think unable to use format function. i tried..
0
Demon
Top achievements
Rank 1
answered on 26 Apr 2011, 08:19 AM
Sorry, I didn't notice you are using client templates :)

In this case you should change the <#= #>  string to <# #> in the client template. Afterwards the content inside the expression is not returned, but evaluated as Javascript code (notice you need a return statement now). For example this is the simplest way to return an unformatted value:


.ClientTemplate("<# return reqstDT; #>")

Now you can use Javascript to format the date client-side and return a concatenated string of tags and formatted values, according to your preference.

http://stackoverflow.com/questions/1056728/formatting-a-date-in-javascript
0
Quang
Top achievements
Rank 1
answered on 26 Apr 2011, 06:23 PM
That is so good to support.
Thank you so much, Demon. 
Tags
Grid
Asked by
Quang
Top achievements
Rank 1
Answers by
Quang
Top achievements
Rank 1
Demon
Top achievements
Rank 1
Share this question
or