有朋友通过Ext.data.DirectStore给combobx绑定过数据么
代码如下
                           xtype: 'combobox',
                            id: 'ctlEMS_NO',
                            editable: true,
                            queryMode: 'local',
                            typeAhead: true,
                            selectOnFocus: true,
                            store: Ext.create('Ext.data.Store', {
                                model: 'dropModel',
                                proxy: {
                                    type: 'direct',
                                    directFn: app.Method.Code,

                                    reader: {
                                        type: 'json',
                                        root: 'data'
                                    },
                                },
                                autoLoad: true
                            }),
                            displayField: 'Text',
                            valueField: 'Value',
                            fieldLabel: '编码',
                            triggerAction: 'all',
                            emptyText: '请选择'
                        }这样绑定的话虽然后台返回了数据,但是绑定不到combobox上,但是用下面一种却没问题  xtype: 'combobox',
                            id: 'ctlEMS_NO',
                            editable: true,
                            queryMode: 'local',
                            typeAhead: true,
                            selectOnFocus: true,
                            store: Ext.create('Ext.data.Store', {
                                model: 'dropModel',
                                proxy: {
                                    type: 'ajax',
                                    url: '../modulehelp.ashx?action=Code',

                                    reader: {
                                        type: 'json',
                                        root: 'data'
                                    },
                                },
                                autoLoad: true
                            }),
                            displayField: 'Text',
                            valueField: 'Value',
                            fieldLabel: '编码',
                            triggerAction: 'all',
                            emptyText: '请选择'
                        }有用过的朋友给我点提示呢,谢谢啦

解决方案 »

  1.   

    4.1+需要配置directCfg的method的getArgs,和4.0-不一样
    Ext4 Ext.data.proxy.Direct directFn示例
      

  2.   

    app.Method.Code和相关配置发出来看看
      

  3.   

    app.Method.Code是访问的后台的代码,已经成功返回json数据了,但是前台就是不显示
      [DirectAction("Method")]
        public class DirectAPI : DirectHandler
        {
            public override string ProviderName
            {
                get
                {
                    return "app.Route";
                }
            }        public override string Namespace
            {
                get
                {
                    return "app";
                }
            }
            [DirectMethod]
            public string TRADE_CODE()
            {
                return GetJSON("select cast(TRADE_CODE as varchar(30)) [Value],TRADE_CODE+'|'+TRADE_NAME [Text] from COP_BIZ");
            }        private string GetJSON(string Sql)
            {            SqlHelper _sqlHelper = new SqlHelper();
                JArray _jarray = new JArray();
                IDataReader dReader = _sqlHelper.ExecuteReader(Sql.ToString());
                while (dReader.Read())
                {
                    _jarray.Add(new JObject(
                       new JProperty("Value", dReader["Value"]),
                       new JProperty("Text", dReader["Text"])
                   ));
                }
                return new JObject(
                        new JProperty("data", _jarray)
                    ).ToString();
            }
        }
      

  4.   

    那个TRADE_CODE 方法就是调用的前台调用的CODE,贴上来的时候发错了
      

  5.   

    发js代码,不是后台的,自己用firebug或者chrome开发人员工具监视下ajax返回的数据是否正确
      

  6.   


    //前台代码
    Ext.onReady(function () {
        Ext.direct.Manager.addProvider(app.Route);    Ext.define("dropModel", { extend: "Ext.data.Model", fields: [{ name: "Value" }, { name: "Text" }] });    var win;
        if (!win) {
            win = Ext.create('widget.window', {
                closable: false,
                closeAction: 'hide',
                width: 530,
                minWidth: 530,
                height: Ext.isIE ? 302 : 310,
                autoShow: true,
                border: true,
                bodyStyle: 'text-align:right;',
                iconCls: 'x-icon-add',
                layout: {
                    type: 'border',
                },
                items: [{
                    region: 'center',
                    xtype: 'panel',
                    border: false,
                    layout: {
                        type: 'border'
                    },
                    items: [{
                        region: 'north',
                        xtype: 'panel',
                        border: false,
                        heigth: 170,
                        contentEl: 'ShowLogo'
                    }, {
                        region: 'center',
                        layout: {
                            type: 'border'
                        },
                        xtype: 'form',
                        id: "formPanel",
                        items: [{
                            region: 'center',
                            xtype: 'panel',
                            bodyStyle: 'background-color: transparent;',
                            border: false,
                            layout: 'form',
                            items: [{
                                xtype: 'combobox',
                                id: 'ctlEMS_NO',
                                editable: true,
                                queryMode: 'local',
                                typeAhead: true,
                                selectOnFocus: true,
                                store: Ext.create('Ext.data.Store', {
                                    model: 'dropModel',
                                    storeid:'test',
                                    proxy: {
                                        type: 'direct',
                                        batchActions: false,
                                        directFn: app.Method.code,
                                        reader: {
                                            type: 'json',
                                            root: 'data'
                                        },
                                    },
                                    autoLoad: true
                                }),
                                displayField: 'Text',
                                valueField: 'Value',
                                fieldLabel: '交易代码',
                                triggerAction: 'all',
                                emptyText: '请选择'
                            }]
                        }]
                    }
                    ]
                }]
            });
        }});后台返回数据{ "data": [ { "Value": "0000001", "Text": "0000001|直接付款" } ] }
      

  7.   

    返回内容由string类型修改成JObject类型就可以了