English 中文(简体)
第一次从JSON公司的答复中装载时,Ext JS 空出的Selector
原标题:Ext JS empty ItemSelector when loaded for the First time from a JSON response

我正在与使用Exjs的Alelector一道制作一个表格。 4. 第四条第4款 我正在利用Json储存,我在那里的反应如下:

{"items":[{"id":"12","name":"Cable"},{"id":"8","name":"Document"},{"id":"1","name":"Equipment"},{"id":"2","name":"Instrument"},     {"id":"10","name":"Isometric"},{"id":"11","name":"Joint"},{"id":"4","name":"Line"},{"id":"3","name":"LineSeg"},{"id":"5","name":"Specialty"},{"id":"6","name":"Spool"},{"id":"7","name":"Valve"},{"id":"9","name":"Weld"}]}

My Form

Ext.require([
         Ext.ux.form.MultiSelect ,
         Ext.ux.form.ItemSelector 
        ]);


Ext.define( MyAPP.view.directory.MyForm , {
    extend:  Ext.form.Panel ,
alias: widget.myform ,
    border: false,
    split: true,
bodyPadding: 5,
lableWidth:30,
autoScroll : true,
defaults: {
    anchor:  100% 

},
defaultType:  textfield ,
items: [
    {
xtype: fieldset ,
title:  Commodities ,
collapsible: true,
border:0,
defaultType:  textfield ,
defaults: {anchor:  100% },
layout:  anchor ,
items :[
      {
        xtype:  itemselector ,
        name:  commoselector ,
        id: commoselector ,
        listAvailable:  ,
        listSelected:  ,
        fieldLabel:   ,
        imagePath:  extjs407/ux/css/images/ ,
        store: Ext.create( MyAPP.store.CommodityStore ),
        displayField:  name ,
        valueField:  id ,
        //value: [ 9 ],
        //allowBlank: false,
        msgTarget:  under 
      }
 ]
},



 initComponent: function () {
    this.callParent(arguments);
}
});

我的仓库

 Ext.define( MyAPP.store.CommodityStore , {

  extend:  Ext.data.Store ,

 constructor: function(cfg) {

 var me = this;
 cfg = cfg || {};
 me.callParent([Ext.apply({
     autoLoad: true,
     autoDestroy: true,
     storeId:  CommodityStore ,
     proxy: {
        type:  ajax ,
        url:  getCommodityList ,
        reader: {
            type:  json ,
            root:  items 
        }
    },
    fields: [
            {name:  id },
            {name:  name }
    ]
   }, cfg)]);
  }
   });

When the form created its not loading the blank store although the JSON is correct. Where am doing wrong? Please help. Thanks in advance

最佳回答
initComponent: function () {
var me = this;
Ext.applyIf(me, {
    listeners: {
    beforerender: {
            fn: me.onFormBeforeRender,
            scope: me
        }
   }
});

me.callParent(arguments);

},

onFormBeforeRender: function(abstractcomponent, options) {
        // where store is created globally like this var store =          Ext.create( TIP.store.CommodityStore );

store.load(function(){
    Ext.getCmp("commoselector").bindStore(store);
});
}

存放汽车

问题回答

您不必像在<条码>上手工制作:Ext.create(......)。 MyAPP.store.C CommoditiesStore ,

What you usually do is just put store: CommodityStore and ExtJs will do the rest automatically.





相关问题
ExtJS load form items/fields from database

I am using ExtJS 3 here. I would like to populate a formpanel from database with fields to be submitted. Basically, I don t know witch fields my form will have and I want to generate all formpanel ...

How to use Ext JS for role based application

I am planning to use Ext JS for a large application. The application s features are role based. When user login, they only see menu and screen features related to them. My server side technology will ...

Dynamically adding a TabPanel to a Panel Region

I have a Panel layout with a TreePanel in one region. A user clicks on an node in the tree and a TabPanel should be displayed in another region with information, editing tools etc. for that tree node....

How to embed Json result within Extjs Panel?

I have some issues with Json result and embed it within the html of the Extjs Panel. Here s that I have managed to get so far. myPanel is embedded within a mainPanel, and I have some shows/hide of ...

Ajax data update. Extjs

I need to keep certain data ( in a grid) up to date and was gonna do a poll to the server every 15 seocnds or so to get the data and refresh the grid, however it feels a bit dirty ( the grid will have ...

Better way to call superclass method in ExtJS

All the ExtJS documentation and examples I have read suggest calling superclass methods like this: MyApp.MyPanel = Ext.extend(Ext.Panel, { initComponent: function() { // do something MyPanel ...

Merged Headers in Ext JS Grid

Is it possible to have two headers in Ext JS grids? I have to show my grid as grouped data.. for example product types and products. In my case I need a grid like this: Field | Product Type A ...

热门标签