DatePicker format in treeview edit template (using bootstrap datepicker)

May 20, 2015 at 2:23 PM
Hi,

I'm a new in MVCCT, and i'm going round and round in circles for hours on a DateFormat.

Here's the context :

I'm using a TreeViewFor (which is working great by the way).
On one Edit template, i need to render a date from my object, on which i can't set the format and language properly.

Here's the code
 _S.H<Relance>(
                            @<div class='file'>
                                @{var monObj=item;}
                                @item.TypedEditDisplayFor(m => m.Niveau, simpleClick: true, editEnabled: true)&nbsp;
                                @item.TypedEditDisplayFor(m => m.REL_ID, simpleClick: true, editEnabled: true)&nbsp;

                                @item.TypedEditDisplayFor(m => m.REL_DT_RELANCE, contentAlign: ContentAlign.Left, calendarOptions: 
                                new CalendarOptions
                                    {
                                         ChangeYear=true,
                                         ChangeMonth=true,
                                         DateFormat="d"
                                    })&nbsp;

                                @item.TypedEditDisplayFor(m=>m.REL_MOTIF, simpleClick: true, editEnabled: true)&nbsp;
                                @item.TreeViewDeleteButton(Url.Content("~/Content/images/document_delete_16.png"),
                                    ManipulationButtonStyle.Image)
                                @item.Hidden("IsFolder", false)
                            </div>
Notes :
  • I use the bootstrap datepicker js
  • I set the globalization in my WebConfig (<globalization uiCulture="fr-FR" culture="fr-FR" />)
  • The DateFormat doesn't work as i expected :
            *  the "D" format render : Fri May 01 2015 00:00:00 GMT+0200 (Paris, Madrid (heure d’été))
            *  the "d" format render : Mon Jan 05 2015 00:00:00 GMT+0100 (Paris, Madrid)
    
Any lead on how i could fix that issue please ?

Thanks,

SanDai
Coordinator
May 22, 2015 at 9:27 AM
TypedEditDisplay helper has a parameter: "overrideClientFormat". The d format should be specified there...but the d format is the default anyway. overrideClientFormat is automatically copied into calendarOptions. The converse is not true. You may also use the FormatAttribute to specify the format on the ViewModel property(preferred way).

However, if date is displayed in english, this means you have not set up properly globalization on the client side ...What you did set globalization on server side...but widgest need to parse and render dates dynamically on the client side. Pls refer to the globalization section.
May 26, 2015 at 6:12 AM
Edited May 26, 2015 at 6:12 AM
Thanks for the lead, I'm gonna try this out !