-
26 May 2011 9:06 AM #11
And when is your solution going to be available? If it is already in place how is it used. I'm also struggling to make a Select widget work with a Store, but so far had to do it manually (i.e. load the store, listen to the load event, fill in the Select's options).
-
29 May 2011 9:04 PM #12
I am also facing same problem. Is it possible now?
-
29 May 2011 9:06 PM #13
Krause,
Could you give me any sample code. I can not forward.
-
30 May 2011 8:46 AM #14
The field:
The store:Code:{ xtype : 'selectfield', name : 'sampleSelectField', label : 'Sample', displayField : 'name', valueField : 'id' // store : store <---- This doesn't work }
Code:var store = new Ext.data.Store( { fields : [ { name : 'id', type : 'int' }, { name : 'name', type : 'string' }], proxy : { type : 'ajax', url : "http://x.x.x.x/rest/entity", reader : { type : 'json', root : 'list' } }, listeners : { load : function(store, recs, success) { // I search for my Select field and manually fill it: var selectField = container.query(".selectfield[name='sampleSelectField]")[0]; selectField.setOptions(recs); } } });
In order to load the store you have to do it programatically beforehand. I didn't find any event that would be called when the select gets triggered by the user so you have to fill it upfront (not very ajaxy...):
Code:store.load( { params : { myParam : someField.getValue() } });Last edited by krause; 30 May 2011 at 3:44 PM. Reason: removed an extra comma in code
-
30 May 2011 3:42 PM #15
With this override to Ext.form.Select it works as expected (by me at least). Please note that this is an untested quick hack that I made while exploring and trying to understand the inner workings of the component. I hope I'm wrong and there actually is already a way to do this without the hacking. I would hate to see the parade of user extensions in the forum as it is for ExtJS.
What I'm doing here is overriding the showComponent function wich shows the list of options and instead I'm firing the store's load method. When the store gets loaded, and only then, I show the list of options for the user to select. This would still need an indicator that the data is loading. You may add a 'beforeload' listener to your store to pass in any required parameters to the ajax call (e.g. if the select depends on the value of another select or field).Code:Ext.override(Ext.form.Select, { originalInitComponent : Ext.form.Select.prototype.initComponent, // @private initComponent: function() { var me = this; if (this.store) { this.store.on('load', function() { me.originalShowComponent(); }); } Ext.form.Select.prototype.originalInitComponent.call(this); }, originalShowComponent : Ext.form.Select.prototype.showComponent, // @private showComponent: function() { this.store.load(); } });
Code:var store = new Ext.data.Store( { . . . listeners : { beforeload : function(store, operation) { operation.params = { myParam : anotherField.getValue() } } } });Last edited by krause; 30 May 2011 at 3:43 PM. Reason: spelling
-
30 May 2011 4:16 PM #16
-
13 Oct 2011 4:37 AM #17
Thanks for sharing!!!
I hope Sencha will offer a native solutions for this soon.
-
5 Feb 2013 3:32 AM #18
Is there now a solution for Selectfield and update a store?
Similar Threads
-
reload store and display grid on OnChange event in select box
By dpn in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 18 Dec 2009, 6:46 AM -
what are my options for a select box
By nmaves in forum Community DiscussionReplies: 4Last Post: 22 Apr 2008, 11:45 AM -
combo/select box?
By Capi666 in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 2 Apr 2008, 11:25 PM -
how to make the combo box working same as the genral html select box
By rajesha in forum Community DiscussionReplies: 0Last Post: 3 Jul 2007, 10:15 PM -
Getting selected value from select box
By KRavEN in forum Ext 1.x: Help & DiscussionReplies: 2Last Post: 15 Mar 2007, 4:33 AM


Reply With Quote
