Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
163
rated 0 times [  167] [ 4]  / answers: 1 / hits: 6531  / 11 Years ago, wed, january 22, 2014, 12:00:00

I have Json data which is retrieving from database by sending an Ajax request.



{'tourData':[{ 'code' : '6', 'ref' : '22/01/2014 09:08:54-Route 2', 'vehicle' : 'GY-122-120', 'fromDate' : '2014-01-22 00:00:00', 'toDate' : '2014-01-22 00:00:00', 'tourAssign' : 'Saman', 'driver' : 'Kamal Subhasingha', 'assistant' : 'Sampath Jayaweera', 'porter1' : 'Namal Witharana', 'porter2' : 'Yohan', 'porter3' : 'Ahan Liyanage' } ]}


I try to set 'fromDate' as the value of a date field.



new Ext.form.DateField({
id : 'fromDateCombo',
fieldLabel : 'From Date',
allowBlank : false,
width : 140,
name : 'fromDate',
emptyText : 'From Date',
hideLabel : true,
format: 'd/m/Y',
style : 'marginleft:10px',
disabled : true,
listeners : {
select : function() {
if (Ext.getCmp('toDateCombo').getValue()< this.getValue()) {
Ext.Msg.show({
title: 'Error',
msg: 'From Date should be less than or equal To Date' ,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
this.setValue(sysDate);
}
}, render: function(c) {
new Ext.ToolTip({
target: c.getEl(),
html: 'From Date'
});
}

}
});


I've tried this.



var jsonData = Ext.util.JSON.decode(response.responseText);  
console.log(jsonData);
if (jsonData.tourData.length > 0) {

Ext.getCmp('fromDateCombo').setValue(Date.parseDate(String(jsonData.tourData[0].fromDate), 'd/m/Y'));

}


But it doesn't set the date and doesn't print any error message in my firebug console.



What's wrong with my codes and how can I fix it ?



Kind Regards


More From » extjs

 Answers
26
var fromDate = jsonData.tourData[0].fromDate;
console.log(fromDate); // it should not be undefined

var value = Date.parseDate(fromDate, Y-m-d H:i:s);
Ext.getCmp('fromDateCombo').setValue(value);

[#48463] Tuesday, January 21, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shylaelisan

Total Points: 37
Total Questions: 94
Total Answers: 110

Location: Angola
Member since Tue, May 5, 2020
4 Years ago
;