May 23, 2012, 12:40 PM
[CLOSED] Dates & Json & ComboBoxes
Hi,
I have a view that renders a list of dates in a ComboBox. I want to controll how that dropdown renders those dates, so I do this:
I have a view that renders a list of dates in a ComboBox. I want to controll how that dropdown renders those dates, so I do this:
<ext:ComboBox ID="ResultsSetCombo" runat="server" FieldLabel="Patching Result Set"
Editable="false" DisplayField="CreationDate" ValueField="FrontEndMappingSetId" TypeAhead="false"
Mode="Local" DataIndex="FrontEndMappingSetId" Width="500" SelectedIndex="0" ItemSelector="div.list-item">
<Store>
<ext:Store ID="FrontEndMappingResultsStore" runat="server" AutoLoad="true">
<Reader>
<ext:JsonReader IDProperty="FrontEndMappingSetId">
<Fields>
<ext:RecordField Name="FrontEndMappingSetId" />
<ext:RecordField Name="CreationDate" Type="Date"/>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<Template runat="server">
<Html>
<tpl for=".">
<div class="list-item">{CreationDate:date("d-M-Y H:i:s")}</div>
</tpl>
</Html>
</Template>
<Listeners>
<AfterRender Fn="onAfterRender" />
<Select Fn="onSelect" />
<Blur Fn="onBlur" />
</Listeners>
</ext:ComboBox>
The problem is, while the items in the dropdown render as I want, the SELECTED item has the default rendering, and for some reason it's getting the time wrong. For example if the time is 17:00 (5pm), it shows as 05:00. I'm loading the combo from data I'm loading the combo's store from JSON loaded in the controller: ViewBag.MappingResultSets = JSON.Serialize(mappingResultSets.OrderByDescending(r => r.CreationDate).Select(c => new { c.FrontEndMappingSetId, c.CreationDate }));
And here is a snippet of the JSON{"FrontEndMappingSetId":25,"CreationDate":"2012-05-22T14:30:39.373"},{"FrontEndMappingSetId":24,"CreationDate":"2012-05-16T14:12:11.883"}
Is this correct? I tried using the default "JavascriptSerializer" which then formats the dates in that /Date()/ Format, but that doesn't seem to work at all.
Last edited by Daniil; May 24, 2012 at 2:49 PM.
Reason: [CLOSED]