PDA

View Full Version : Store with Combo Box



sridhar.boganathan
8 Jun 2012, 3:47 AM
Hi All,

I have a combo box in a form (Ext.form.Panel) and I have configured a store to this combo box. At the first time loading of the forms, the store object which is configured with the combo box requesting the server for the data. Second time loading of the form, it is not requesting the server.

But it has to request the server for each and every time of form loading as per my requirement. I could not find a way to do this.

Please let me know what / where I am wrong and let me know the method to do.


//form
Ext.define('studentspoc.view.students.Details' ,{
extend: 'Ext.form.Panel',
alias : 'widget.studentdetails',
loaderMask: null,
items: [{
xtype: 'textfield',
fieldLabel: 'Roll No.',
name: 'rollno',
width: 100,
disabled: true
},{
xtype: 'combobox',
fieldLabel: 'Subject',
store: Ext.create('studentspoc.view.store.Subjects'),
queryMode: 'local',
displayField: 'name',
valueField: 'subjectid',
disabled: true
}]
});

//store
Ext.define('studentspoc.view.store.Subjects',{
extend: 'Ext.data.Store',
autoLoad: true,
fields: [
{name: 'subjectid'},
{name: 'name'}
],
autoLoad: true,
proxy: {
type: 'ajax',
url: serverulr,
reader: {
type: 'xml',
root: 'lines',
record: 'subjects'
},
actionMethods: {
read: 'POST'
},
headers: {
"Content-Type" : 'text/xml'
}
}
});

-Sridhar

dedoz
8 Jun 2012, 4:04 AM
post code where you "reload" the form (Second time loading of the form) maybe there, before showing your form for second time, you can do a store.load();

or if your combo data changes alot, then maybe set queryMode:remote (check docs for that)

sridhar.boganathan
10 Jun 2012, 10:16 PM
post code where you "reload" the form (Second time loading of the form) maybe there, before showing your form for second time, you can do a store.load();

or if your combo data changes alot, then maybe set queryMode:remote (check docs for that)

Thanks dedoz. I have tried this way creating an instance of this class when form is loaded. But second time creation of the store class doesn't seem to be requesting the server.

Are you mentioning to define the store class dynamically and create instance of it?

-Sridhar

sdt6585
11 Jun 2012, 4:54 AM
I've found it usefull to add a beforeload and afterload event to the regular form to allow yourself to handle situations like this. If you were to do that, you could just attach a listener to the form and reload the combo box store everytime the form loads. You might even be able to extend the combobox class and make it register a listener with whatever form it is added to. In any case, this is the extended form I use to create load events...after looking at it, I imagine the form.loadRecord() function is asynchronous so the after event probably fires before the data is actually loaded, but it should still serve your purposes.



Ext.define('Ext.ux.form.Panel', {
extend: 'Ext.form.Panel',

loadRecord: function (record) {
this.fireEvent('beforeLoadRecord', record);
this.callParent(arguments);
this.fireEvent('afterLoadRecord', record);
},

updateRecord: function (record) {
this.fireEvent('beforeUpdateRecord');
this.getForm().updateRecord(record);
this.fireEvent('afterUpdateRecord');
}
});