PDA

View Full Version : Saving a Timefiled with the correct Date-Format in a Store



hoyt
11 Mar 2013, 2:49 AM
Hello everyone.

This is my timefield which is inside a panel.:

xtype: 'timefield',
name: 'mo1v',
itemId: 'mo1v',
format: 'H:i',
minValue: '0:00',
maxValue: '12:00',
increment: 15

Here's how I declare my Store:


Ext.define('StoreName', {
extend: 'Ext.data.Store',
fields: [mo1v]
});

After fireing the getValues() function which is fetching the current value of each field in the form, i got the following time-format: e.g. "03:15". So far so good.

After fireing the loadRawData or loadData function the timefield is loaded into a store


Ext.StoreMgr.lookup('StoreName').loadRawData(getValues, true);


Now, I need to retrieve the Data out of the Store.

var openingHoursStore = Ext.StoreMgr.lookup('StoreName');
openingHoursStore.each(function(record) {
... do something ...
}

After retrieving the data out of the store, the Timeformat looks like this: Date {Tue Jan 01 2008 02:30:00 GMT+0100}
But I need the starting size "03:15".

Declaring a dateFormat: 'H:i' or type: 'date' in the Store does not work.

Any help here would be great.

mitchellsimoens
12 Mar 2013, 3:23 PM
Do you have type : 'date' for that field in the store? If so then it will parse the string into a date object. The dateFormat config in the field is just to say what format the string is.