在extjs错误填充组合中使用ajax请求

时间:2016-07-06 10:34:00

标签: asp.net ajax extjs

工作代码:

var CustomStore = new Ext.data.Store({

    model: 'User',
    proxy: {
        type: 'ajax',
        url: 'http://Test/Service1.svc/GetOperator',
        pageParam: false, 
        startParam: false, 
        limitParam: false, 
        noCache: false, 

        params: {
            storeID: 31
        },
        autoSync: true,
        reader: {
            type: 'json',
            root: 'users'
        }

    },

    autoLoad: true
});
Ext.define('User', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'StaffID', type: 'string' },
        { name: 'Name', type: 'string' }
    ]
});

声明绑定

               }, {
               id: 'cmbAppOperator',
               itemId: 'OperatorId',
               name: Ext.calendar.data.EventMappings.OperatorId.name,
               fieldLabel: 'Operator',
               xtype: 'combo',
               anchor: '60%',
               store: CustomStore,
               valueField: 'StaffID',
               displayField: 'Name',
               queryMode: 'local',
               allowBlank: false
           },

这是json

下面的工作代码

但错误同样只是更改了请求的网址

json回答如下:

[
 {
  "Name": "-Any Operator-",
 "StaffID": 0
 },
 {
 "Name": "aa Manzie",
 "StaffID": 37
 },
{
"Name": "tttt Sadsad",
"StaffID": 33
}
]
  

“{\”OperatorListForAppointment \“:[{\”Name \“:\”任何运算符\“,\”OperatorID \“:0},{\”名称\“:\”aa Manzie \“,\ “OperatorID \”:37}]}“

下面是代码

var CustomStore = new Ext.data.Store({

    model: 'User',
    proxy: {
        type: 'ajax',
        limitParam: 'false',
        noCache: false,
        pageParam: 'false',
        startParam: 'false',            

        url: 'https://test/POS/SalesService.svc/GetOperatorListForAppointments',
        params: {
            storeID: 31,
            shiftDate: '2016-07-05 04:29:36.840',
            dataBaseName: 'DB_Test'
        },
        autoSync: true,
        reader: {
            type: 'json',
            root: 'users'
        }

    },

    autoLoad: true
});
     Ext.define('User', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'OperatorID', type: 'string' },
        { name: 'Name', type: 'string' }
    ]
});
              }, {
               id: 'cmbAppOperator',
               itemId: 'OperatorId',
               name: Ext.calendar.data.EventMappings.OperatorId.name,
               fieldLabel: 'Operator',
               xtype: 'combo',
               anchor: '60%',
               store: CustomStore,
               valueField: 'OperatorID',
               displayField: 'Name',
               queryMode: 'local',
               allowBlank: false
           },

我很困惑,请让我知道我哪里错了。

1 个答案:

答案 0 :(得分:0)

必须在商店代理中将root属性定义为OperatorListForAppointment而不是用户,因为您的响应JSON包含作为OperatorListForAppointment的数组属性。