PDA

View Full Version : To a Store how to add a new Field to it with the Field already present ?



gameboy87
20 Jul 2012, 3:11 AM
I have a Store. And 5 fields are there. From one of a field(having timestamp value) I want create a new Field which is of type Date type. How can this be Done ? Thanks.

tobiu
20 Jul 2012, 3:47 AM
take a look at:
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Field-cfg-convert

gameboy87
20 Jul 2012, 6:00 AM
Thanks for replying. I will take a look.

gameboy87
20 Jul 2012, 6:41 AM
I tried with as above mentioned and I was not able to get it,

function convertfromDate(v, record)
{
var tstamp = record.day;
console.log(tstamp); //This was printing undefined
var dd = new Date(tstamp * 1000);
//console.log(dd);
return dd;
}


And this is the store excerpt

{name:'day', type:'int'}, // this has some value like 1342160000
{name:'fromDate', convert:convertfromDate},


Please help !

droessner
20 Jul 2012, 7:25 AM
Try changing var tstamp = record.day; to var tstamp = record.get('day');

gameboy87
22 Jul 2012, 7:50 PM
Thanks droessner, tobiu . It helped me a lot. :)