2013年9月16日星期一

Rookie help, initializes a extjs combox, but can not get the values ??

 This post last edited by the toss2000 on 2011-03-30 09:20:38
one needs to initialize a combox, want to immediately get its value , the results can not be obtained , please help pointing twelve brothers combox following initialization code
var templateStore = new Ext.data.JsonStore ({
url: '.. / templateManage.do? method = queryAllTemplate',
root: 'root',
fields: [{
name: 'reportId',
type: 'int'
}, {name: 'name', type: 'string'}],
autoLoad: true,
listeners: {
load: function () {
Ext.getCmp (combo.id). setValue (templateStore.getAt (0). get ("reportId"));
}
}
});
combo.id represents a combox id value , I want to do right away to get the value of combox other users as a result, through combo.getValue () to get an empty value, brothers see how it has there is no better way Here are some of the code combo
var combo = new Ext.form.ComboBox ({
id: 'comboId',
fieldLabel: ' Letters template selection ',
store: templateStore,
name: 'reportId',
......
------ Solution ---------------------------------- ----------
I'll give you an example see it

var user_dataProxy = new Ext.data.HttpProxy({
        url: '__URL__/usershow',
        method: 'POST'
    });

  var user_dataReader = new Ext.data.JsonReader({
   root: 'root',
   id: 'id',
   fields:['id','name']
   });

var user_store = new Ext.data.Store({  
    proxy: user_dataProxy,
    reader: user_dataReader,
    autoLoad: true

});
   var combouser =new Ext.form.ComboBox({
         xtype:"combo",
      fieldLabel: 'Author',
      name: 'authorlist',
store:user_store,
           
              displayField:'name',        
              valueField: 'id',        
              mode: 'remote',
              editable:false,
              width:200,
      triggerAction: 'all',       
      emptyText:'Select an user',
      //readOnly: true, 
      hiddenName: 'author' 
     });

------ Solution ------------------------------------- -------
your logic issues now

When you load data request does not return you to fetch data ~ ~

You can at any other time values ​​such as the bottom of the whole page is loaded to write a method in which access to the upper combox value
------ For reference only ---- -----------------------------------
get their own , as follows , and I hope the brothers needed who help
var templateStore = new Ext.data.JsonStore ({
url: '.. / templateManage.do? method = queryAllTemplate',
root: 'root',
autoLoad: true,
fields: [{
name: 'reportId',
type: 'int'
}, {name: 'name', type: 'string'}]});

templateStore.on ('load', function ()
{
combo.setValue (templateStore.getAt (0). get ("reportId"));
historyStore.baseParams.conditions = combo.getValue () ;/ / Note that only in this place get combo.getValue () value , this value can not be obtained elsewhere , historyStore also a data sets, to first obtain combo.getValue () for loading the value as a parameter
historyStore.load ();
});
first sun drying , after Jietie
------ For reference only ---------------------------- -----------
actually no attention , well, Jietie the
------ For reference only -------------- -------------------------
very good, very good, very good, very good, very good, very good, very good, very good ,
------ For reference only ------------------------------------ ---
today happens to encounter this problem, try
------ For reference only ----------------------- ----------------
help it a bit , but, and my problem is not the same

没有评论:

发表评论