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

[Solved] Date Time format on Grid

3 Answers 517 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.
Bill
Top achievements
Rank 1
Bill asked on 04 Sep 2010, 06:17 AM
Can someone tell me if this is the expected behavior with DateTime columns when you switch from Display Mode to Edit Mode?

Display Mode: 07/27/2010 12:00

Edit Mode: Tue Jul 27 00:00:00 PDT 2010

Furthermore when I switch back to Display Mode for the row, the format doesn't change back and stays at Tue Jul 27 00:00:00 PDT 2010. Am I supposed to add some JavaScript or perhaps clean up the Model data?

3 Answers, 1 is accepted

Sort by
0
Jigar
Top achievements
Rank 1
answered on 08 Sep 2010, 08:44 AM
Hi Bill,

Try this;

For Column:
columns.Bound(Function(c) c.createddatetime).Format("{0:d}")

For Details-View:
DetailView(Sub(dtView)                                                                 dtView.ClientTemplate("<div><ul><li><#= getDateInFormat(createddatetime) #></li></ul></div>")                                                                     
End
Sub)
<script type ="text/javascript">
    function getDateInFormat(myValue) {
        return $.telerik.formatString("{0:d}",myValue);
    }
</script>  

Hope this helps.

thanks.

0
Bill
Top achievements
Rank 1
answered on 24 Sep 2010, 06:01 AM
looks like I'm more or less doing that already. It works initially but reverts back after you click Edit.

  col.Bound(bat => bat.BargeActivityDateTime)
                 .Format("{0:MM/dd/yyyy hh:mm tt}")
                 .Width(150)
                 .Title("Date & Time");   

0
Forest
Top achievements
Rank 1
answered on 04 Jul 2011, 10:17 PM
I've had this issue as well.

What I did to solve it is actually a solid design principle if you're using View Models.  Basically, add a string property to your View Model class to return the Date formatted the way you want.

I'm sure there's a way to convert it on the client-side via JavaScript, but consider the View Model approach as well. 

Tags
Grid
Asked by
Bill
Top achievements
Rank 1
Answers by
Jigar
Top achievements
Rank 1
Bill
Top achievements
Rank 1
Forest
Top achievements
Rank 1
Share this question
or