extjs--combox 동적 할당

2371 단어


if (typeof (InitData) == 'undefined' || InitData == null) { InitData = {}; }

InitData.Terminal = {
    terminalNos: [{id:'', name:' '}] // 
}
//  
InitData.init = function () {
    //  
    Com.Ajax.createAjaxRequest({
        url: 'Data/GetTerminalData',
        succFn: function (obj) {
            for (var i = 0, max = obj.data.items.length; i < max; i++) {
                var ter = obj.data.items[i];
                InitData.Terminal.terminalNos.push({ id: ter.id, name: ter.name });
            }
        }
    });
}


//  

var t_store = Ext.create('Ext.data.Store', {
            fields: ['id', 'name'],
            data: InitData.Terminal.terminalNos,
            proxy: {
                type: 'memory',
                reader: {
                    type: 'json',
                    root: 'items'
                }
            }
        });
        var tercombo = Ext.create('Ext.form.ComboBox', {//  : 
            fieldLabel: ' ',
            id: id_combo_terminal,
            name: 'slipInfo.Terminal',
            labelWidth: 80,
            width: 278,
            value: '', //  
            store: t_store,
            editable: false, //  , 
            queryMode: 'local', //  'local'
            //triggerAction: 'all',
            valueField: 'id',
            displayField: 'name'

        });

c# 백그라운드
List<Hashtable> list = new List<Hashtable>();
            Hashtable rtnVal = new Hashtable();
            List<string> terlist = Common.TerminalNo.TERMINAL_LIST;
            
            if(terlist != null) 
            {
                for(int i=0; i<terlist.Count(); i++) 
                {
                    Hashtable ht = new Hashtable();
                    ht["id"] = terlist[i];
                    ht["name"] = terlist[i];
                    list.Add(ht);
                }
            }
            rtnVal["totalcount"] = terlist.Count();
            rtnVal["items"] = list;
            return CreateJsonResult(true, data: rtnVal);

좋은 웹페이지 즐겨찾기