PDA

View Full Version : [CLOSED] timefield editor default date



redi
Aug 20, 2014, 4:36 AM
I'm having problem with timefield editor in datecolumn. I have two datecolumn with timefield editor, "StartTime" and "EndTime"

The first time it's loaded, the StartTime show "19:00" which it got from database which it's real value is "1900-01-01 19:00". If I choose another StartTime, for example "20:00" the value I got is "1900-01-01 20:00".

And then when I select an EndTime from the dropdown timefield editor, from code behind, this is the value I got "2008-01-01 20:30". The EndTime timefield editor use date "2008-01-01" as it's default date value.

So when I want to get the time difference between 19:00 to 20:30, I can't get the right value, because it also take into count the date difference. My question is how to set the day-month-year of timefield to always refer to the same default value, in this case to "1900-01-01"?

This is my code and screenshots

http://forums.ext.net/attachment.php?attachmentid=14601&stc=1 http://forums.ext.net/attachment.php?attachmentid=14611&stc=1




<ext:GridPanel ID="GridPanel2" runat="server" fittoframe="true" AutoScroll="True" MaxHeight="250">
<Store>
<ext:Store ID="STR1" runat="server">
<Model>
<ext:Model runat="server" ID="Model1">
<Fields>
<ext:ModelField Name="StartTime" Type="Date" />
<ext:ModelField Name="EndTime" Type="Date" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel2" runat="server" DefaultSortable="false">
<Columns><ext:DateColumn ID="Column1" runat="server" Text="Start Time" DataIndex="StartTime" Width="100" Format="H:i">
<Editor>
<ext:TimeField ID="edStartTime" runat="server" Format="H:i"/>
</Editor>
</ext:DateColumn>
<ext:DateColumn ID="Column2" runat="server" Text="Time End" DataIndex="EndTime" Width="100" Format="H:i">
<Editor>
<ext:TimeField ID="edEndTime" runat="server" Format="H:i"/>
</Editor>
</ext:DateColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>

Daniil
Aug 20, 2014, 4:58 AM
Hi @redi,


My question is how to set the day-month-year of timefield to always refer to the same default value, in this case to "1900-01-01"?

I think it might be problematic to do.

I would recommend to set the same date for both the values when you need to get the difference between them.

raniara
Aug 20, 2014, 5:05 AM
I think I'm having the same problem. Where is that date 2008-01-01 come from?

Daniil
Aug 20, 2014, 6:05 AM
From here:
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.picker.Time-property-initDate

redi
Aug 22, 2014, 8:54 AM
How can we change the default date?

Daniil
Aug 22, 2014, 9:44 AM
You can put this JavaScript code into the page's <head> head.

Ext.picker.Time.prototype.initDate = [1900, 0, 1];