您的位置:首页 > 其它

关于Ext的Combo加载数据的问题。

2014-05-23 15:38 176 查看
 
  在combo的配置选项中有个mode,我们可以配置两个参数,local,remote 从字面意思上看,一个是本地加载,一个是远程加载。

    于是就出现了一个问题,我用jsonStore去后台取数据的时候,认为数据是从后台来的所以设置mode为remote,但是combo并没有显示数据出来,从fireBug看到我拿到了正确的数据。试了很久都没解决,后来看到自己代码的store是这样的。

var store = new Ext.data.JsonStore({

      url:'getClientNameList.action',

      root:'root',

      autoLoad:true,

      fields : [{name:'text'},{name:'value'}]

  }); 

     突然蹦出个想法,会不会是数据已经取回本地了(注意autoLoad:true,)于是改动mode:'local' ,测试成功。于是想是不是自己想错了, mode 的方式remote 和 local是字面上的意思那样么,发现文档是这样写的:
Acceptable values are: 'remote' : Default Automatically loads the store the first time the trigger is clicked. If you do not want the store to be automatically loaded the first time the trigger is clicked, set to 'local' and manually load the store. To
force a requery of the store every time the trigger is clicked see lastQuery. 'local' : ComboBox loads local data


    意思大概是说,combo在第一次点击下拉按钮的时候会自动的load store ,竟然是这样为什么我设置成remote的时候点击下拉不会加载呢?

    于是怀疑是不要吧autoLoad:true去掉,因为觉得既然combo把你load了就不需要了,后面发现想错了autoLoad去掉默认也是true,应该是写为false,

总结

     …………………………………………………………………………
参考地址:http://www.verydemo.com/demo_c113_i14001.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: