1

我在 Extjs 中创建了一个组合框,其中显示了报告的名称,当用户选择任何报告时,应该在后端发布报告的 id。我无法获得报告的 ID。我正在使用商店在组合框中填充数据。

我在 Extjs 中创建了一个模型,例如

Ext.define('Report', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'ReportId', type: 'int'},
        {name: 'DisplayName',  type: 'string'}
    ]
});

商店就像

 var reportStore = Ext.create('Ext.data.Store', {
    model: 'Report',
    autoLoad: true,
    proxy: {
        type: 'ajax',
        url: 'reportlist.json'
});

像组合框

var comboReports = Ext.create('Ext.form.field.ComboBox', {
    displayField: 'DisplayName',
   valueField: 'ReportId',
   fieldLabel: 'Report',
    store: reportStore,
    queryMode: 'local',
    emptyText: 'Select a report',
    selectOnFocus: true,
    listeners: {
            select: function(combo, selection) {
                if (combo.getValue()) {
        //showData(reportId); here i want the id of seleted report to passed.

                }
            }
        }
    });
4

1 回答 1

7

实际combo.getValue()返回选中项的reportId。 showData(combo.getValue());是你需要的。

于 2012-08-31T07:49:57.313 回答