-
11 Nov 2011 9:58 AM #1
Select Field with AJAX Store (with Model) behind it does not display selected item
Select Field with AJAX Store (with Model) behind it does not display selected item
REQUIRED INFORMATION Ext version tested:
- Sencha Touch 2.0 rev PR2
- Chrome 15
- Safari 5
- html5
- When there is an AJAX (rest) store behind a selectfield, it loads the data fine.
- However when you select the item from the picker it does not populate the display field and does not set the value.
- Render selectfield in a formpanel.
- Select item from select picker
- Item selected would be displayed in the field
- Item selected would be added to the backing form values.
- Item selected not displayed in the field.
- form.getValues() shows item value as null
- Side Note: The layout seems to be a bit weird also. Note how zip code does not have a bottom border and it looks like the label 'starts over'. Am I not using hbox properly?
HELPFUL INFORMATIONCode:Ext.define('SuperQualifier.model.Location', { extend : 'Ext.data.Model', fields : [{ name : 'locationName', type : 'string' }, { name : 'id', type : 'int' }], proxy : { type : 'rest', url : '../loanQualifier/getLocationTypes', reader : { type : 'json', root : '' } } }) Ext.define('SuperQualifier.store.Locations', { extend : "Ext.data.Store", model : 'SuperQualifier.model.Location', requires : 'SuperQualifier.model.Location', // data : [{ // locationName : 'Test', // id : 1 // }, { // locationName : 'ABc', // id : 2 // }] }) Ext.setup({ onReady : function() { var locationsStore = Ext.create('SuperQualifier.store.Locations'); locationsStore.load() var popup = Ext.create('Ext.Panel', { modal : true, centered : true, layout : 'fit', width : 750, height : 350, hideOnMaskTap : false, scrollable : false, alias : 'widget.addpropertypopup', items : [{ docked : 'top', xtype : 'toolbar', title : 'New Property' }, { xtype : 'formpanel', scrollable : false, items : [{ xtype : 'fieldset', instructions : 'Please fill out above information.', items : [{ xtype : 'textfield', name : 'address', label : 'Address', required : true, autoCapitalize : true, }, { layout : 'hbox', items : [{ xtype : 'textfield', name : 'city', label : 'City', required : true, flex : 2, autoCapitalize : true, }, { xtype : 'textfield', name : 'state', label : 'State', flex : 1, labelWidth : '50%', required : true }, { xtype : 'numberfield', name : 'zip', label : 'Zip', flex : 1, required : true }] }, { xtype : 'selectfield', name : 'location', label : 'Location', displayField : 'locationName', valueField : 'id', store : locationsStore }] }, { layout : 'hbox', defaults : { xtype : 'button', flex : 1, style : 'margin: .5em' }, items : [{ ui : 'confirm-round', text : 'Add', id : 'addpropertybutton', handler : function() { that.submitAddPropertyForm(popup.down('formpanel')) } }, { ui : 'round', text : 'Cancel', id : 'canceladdpropertybutton', handler : function() { popup.hide() popup.destroy() } }] }] }], }); popup.show() } });
-
11 Nov 2011 10:05 AM #2Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,652
- Vote Rating
- 14
Thank you for the report.
-
15 Nov 2011 11:13 AM #3
Good find. I've updated the component to take remote stores into account, yet still allowing for the value config to work as it should.
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
5 Mar 2012 9:27 AM #4
I am using Touch 2.0 RC, and the data returned from the ajax call doesn't seem to be rendered properly in the selection list. The items were listed as "blank" (please see the attached screen shot).
Did I miss anything?
Here is my testing codes and data:
test.jsonCode:Ext.setup({ onReady: function() { Ext.define('TestModel', { extend:'Ext.data.Model', fields: [ {name:'text'}, {name:'value'} ] }); var testStore = Ext.create('Ext.data.Store', { autoLoad:true, model:'TestModel', proxy: { type:'ajax', url:'test.json', reader: { type:'json', rootProperty:'items' } } }); var form = Ext.create('Ext.form.Panel', { scroll:'vertical', url:'', fullscreen:true, items: [{ xtype:'fieldset', title:'Test Form', defaults: { labelAlign:'left' }, items: [{ xtype:'selectfield', label:'Item', valueField:'value', displayField:'text', placeHolder: 'Select something...', store:testStore }] }] }); form.show(); } });
Code:{ "items":[ {"text":"first","value":"1"}, {"text":"second","value":"2"} ] }
-
27 Mar 2012 1:58 PM #5
When using Ext.define, all configs need to go inside the config block:
Code:Ext.define('MyModel', { extend: 'Ext.data.Model', config: { fields: ['text', 'value'] } });Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1023
in
2.0.


Reply With Quote