开发者

populate the combobox dynamically in ExtJs

开发者 https://www.devze.com 2023-03-13 06:45 出处:网络
I want to populate the combobox dynamically based on the data I received from thr Url(which is servlet)

I want to populate the combobox dynamically based on the data I received from thr Url(which is servlet)

Below is my ExtJS code :

{ 
    xtype:'combo', 
    id: 'shoutoutsTags',
    fieldLabel: 'Tag',
    value: '',
    mode: 'local',
    width: 200,
    store: new Ext.data.JsonStore({
        id:'ms',                                   
        url:'http://localhost:8080/ezdi/extServlet',
        //totalProperty:'totalCount',
        root:'rows',
        fields:[
          {name:'un'},
          {name:'pwd'}
        ], 
        autoLoad:true      
    }),
    displayField: 'un',
    valueField: 'pwd',
    typeAhead:true,
    minChars:1,
    forceSelection: true,
    triggerAction: 'all',
    hideTrigger:true
    //hiddenName: 'mytag'
}

But I am getting below error and my Url is not being called:

msg : "You are using a ServerProxy but have not supplied it with a u开发者_如何学JAVArl."

sourceClass : "Ext.data.proxy.Server"

sourceMethod : "buildUrl" uncaught exception: You are using a ServerProxy but have not supplied it with a url.

Suggest me how can I overcome this error.


 Ext.define("modelname", {
    extend: 'Ext.data.Model',
    proxy: {
        type: 'ajax',
        url : '/myServlet',
        method:'POST',
        reader: {
            type: 'json',
            root: 'rows'
            //,totalProperty: 'totalCount'
        }
    },

    fields: [
        {name: 'name', mapping: 'name'}
    ]
});

   var ds = Ext.create('Ext.data.Store', {
       pageSize: 10,
       model: 'modelName'
   });


Your store needs to be updated to use the new Ext JS 4 data model:

var store = Ext.create('Ext.data.Store', {
    model: 'MyNamespace.StoreModel',
    proxy: {
        type: 'ajax',
        url: 'http://localhost:8080/ezdi/extServlet',
        reader: {
            type: 'json',
            root: 'rows',
            totalProperty: 'totalCount'
        }
    }
});

You'll notice here that the store has a property 'model', which is a string, and that there is no field mapping. This is because you'll also need to create a model for the store to reference, like so:

Ext.define('MyNamespace.StoreModel', {
    extend: 'Ext.data.Model',
    fields: [
        {name:'un'},          
        {name:'pwd'}
    ]
});

Hope this helps!


Thats not a valid url, you'll want just '/ezdi/extServlet'.

0

精彩评论

暂无评论...
验证码 换一张
取 消