Ext.js ComboBox不显示JSON数组

时间:2015-06-16 12:26:46

标签: javascript arrays json extjs combobox

我已经检查,检查并再次检查,无法让comboBox显示数据。

JSON数组是:

{"DepartmentData":[{"Department":"Company
Holidays","DepartmentHeadUserID":"74"},{"Department":"Despatch"
,"DepartmentHeadUserID":"70"},{"Department":"Fabric 
Shades","DepartmentHeadUserID":"159"}]}...

哪个加载完全正常,但由于某种原因,comboBox没有使用数组来填充。

Ext.onReady(function(){
    var comboStore = new Ext.data.JsonStore({
    autoLoad: true,

    url: 'includes/DataGet.php',
    storeId: 'DepartmentData',

    root: 'DepartmentData',
    idProperty: 'Department',
    fields: ['Department','DepartmentHeadID'],
    });




    Ext.form.Field.prototype.msgTarget = 'side';




    var simple = new Ext.FormPanel({
    labelWidth: 75,
    url: 'DataStore.php',
    frame:true,
    title: 'Holiday Request Form',
    bodyStyle: 'padding:5px 5px 0',
    width: 350,
    defaults: {width: 230},
    defaultType: 'textfield',




    items: [

        new Ext.form.ComboBox({
        fieldLabel: 'Department',
        name: 'Department',
        id: 'Department',
        forceSelection: true,
        typeAhead: true,
        triggerAction: 'all',
        lazyRender: true,
        store: comboStore,
        emptyText: 'Please Select...',
        mode: 'remote',
        displayField: 'Department',
        valueField: 'DepartmentHeadID',
        allowBlank: false
        }),
    ],

    buttons: [{
    text: 'Submit'
    },{
    text: 'Cancel'
    }]
});

 simple.render(document.body);

});

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

你不会相信这......

我从PHP文件中发送了2个JSON数组,当我评论第二个发布这个帖子时它起作用了。

似乎我需要设置&在JSON Store上发送params,然后在PHP文件中使用switch语句发送回所需的数组。