-
3 Apr 2012 7:21 AM #1
Unable to load data value in simplestore dynamically
Unable to load data value in simplestore dynamically
Hi All,
I am fairly new to ExtJS.
I am trying to load my combo box on depending upon selected value from the previous combo box. (Same Old Country-state scenario) i am making an ajax call and getting values too and assigning in 'data' but it is showing just 2nd character of my variable.
from ajax's call I am assigningCode:attributeStore = new Ext.data.SimpleStore({ fields: ['idc','criteria'], data : [ sb ] }); var tempcriteria = Ext.getCmp('criteriaId'); tempcriteria.bindStore( attributeStore );
But all I am getting is ' <single inverted comma>. Since its the 2nd character in sb.Code:sb = ['CITY_NAME','CITY_NAME'],['CNTRY_NAME','CNTRY_NAME'],['STATUS','STATUS']
I tried changing data to
My combo box is filled with 'b'Code:data : ['sb']
Its bit weird thing happening. I even tried
which works smoothly.Code:data : [['CITY_NAME','CITY_NAME'],['CNTRY_NAME','CNTRY_NAME'],['STATUS','STATUS']]
I am assuming I am making a silly mistake somewhere.
Appreciate any help.
Regards,
M. Rizwan Khan
-
3 Apr 2012 7:26 AM #2
-
3 Apr 2012 7:44 AM #3
Hi Aconran,
Thanks for quick response.
Yeah this works
data : [['CITY_NAME','CITY_NAME'],['CNTRY_NAME','CNTRY_NAME'],['STATUS','STATUS']]but when assigning
sb = ['CITY_NAME','CITY_NAME'],['CNTRY_NAME','CNTRY_NAME'],['STATUS','STATUS']
at runtime and then giving
attributeStore = new Ext.data.SimpleStore({
fields: ['idc','criteria'],
data : [ sb ]
});
it is just displaying ' <single inverted comma> in combobox.
Regards,
M. Rizwan Khan
-
3 Apr 2012 8:01 AM #4
Try
Code:sb = [['CITY_NAME','CITY_NAME'],['CNTRY_NAME','CNTRY_NAME'],['STATUS','STATUS']]; attributeStore = new Ext.data.SimpleStore({ fields: ['idc','criteria'], data : sb });Aaron Conran
@aconran
Sencha Architect Development Team
-
3 Apr 2012 8:16 AM #5
Yeah, what you suggested worked.
But when assign the my String to 'sb' it doesnt work.
I understood the problem is I am giving a String to 'data' whereas it is expecting array of array.
Thanks Acronran. I'll now have to convert my String ([['CITY_NAME','CITY_NAME'],['CNTRY_NAME','CNTRY_NAME'],['STATUS','STATUS']])
to array of array, Don't wanna be a burden but any idea how to do that ?
Regards,
M. Rizwan Khan
-
3 Apr 2012 8:22 AM #6
an unsafe way would be to simply eval it.
A safer way would be to stick it into a JSON object, decode it and then use that.Aaron Conran
@aconran
Sencha Architect Development Team
-
3 Apr 2012 11:03 AM #7
Thanks a lot aconran. Gone with the unsafe way and its working now.
Cheers,
M. Rizwan Khan


Reply With Quote