我是一個使用Extjs 4.07的新手。我創建了一個組合框(遠程)queryMode。組合框顯示課程列表。然而,我最近工作的機構重新編寫了他們的整個課程。所以,我最終有兩個記錄具有相同的顯示字段。我的JSON如下所示:Extjs Comobobox重複顯示字段不允許設置?
{"result":[{"id":"90223","code":"CM12","description":"Introduction to C Programming","creditHours":"3.00","numberOfLabs":"0","contactHours":null,"chargeableCredits":null},
{"id":"2094","code":"CMPS1302","description":"Introduction to C Programming","creditHours":"3.00","numberOfLabs":"0","contactHours":null,"chargeableCredits":null}],"total":2}
顯示字段是描述,值字段是id。當我選擇組合框中的其中一個項目並提交時,一切正常。如果稍後我選擇不正確的課程並選擇另一個,則會出現問題。
我曾嘗試設置idProperty:'id'但無濟於事。當我提交表格時,將發送的值是先選擇的值。注意:這隻發生重複的課程描述,其他一切正常。
這裏是一些代碼來幫助說明問題:
Ext.define('SIS.model.ManageCourse', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
{name: 'code', type: 'string'},
{name: 'description', type: 'string'},
{name: 'creditHours', type: 'float'},
{name: 'contactHours', type: 'float'},
{name: 'chargeableCredits', type: 'float'},
{name: 'numberOfLabs', type: 'float'},
{name: 'selected', type: 'bool'} //for update course pre-requisites
]
});
Ext.define('SIS.store.ClassCourse', {
extend: 'Ext.data.Store',
autoLoad: true,
autoSync: true,
model: 'SIS.model.ManageCourse',
pageSize: 7,
remoteFilter: true,
idProperty: 'id',
proxy: {
type: 'ajax',
api: {
read: 'course/select'
},
reader : {
type : 'json',
root : 'result',
totalProperty : 'total',
successProperty : 'success'
}
}
});
Ext.define('SIS.view.class.ClassCourseCombo', {
extend: 'Ext.form.ComboBox',
alias: 'widget.ClassCourseCombo',
name: 'courseId',
fieldLabel: 'Course',
store: 'ClassCourse',
queryMode: 'remote',
pageSize: 7,
displayField: 'description',
valueField: 'id',
allowBlank: false,
hideTrigger: true,
forceSelection: true,
minChars: 1,
lazyInit: false,
listConfig: {
getInnerTpl: function() {
return '<div class="combo-header">{description}</div>\
<div class="combo-item">{code}</div>';
}
}
});
你能否用例子解釋你的問題「如果以後我選擇了不正確的過程並選擇另一個,就會出現問題。」令人困惑。 – Maggie 2012-03-02 01:08:35
假設我想選擇Intro to C Programming(CM12),但是我錯誤地選擇了Intro to C Programming(CMPS1302)。即使我進行了更正,我的第一個選擇也會被提交。但是,如果我選擇其他課程,例如。軟件工程師,然後選擇Intro to C Programming(CMPS1302),這是可以接受的。 – winkie 2012-03-02 06:36:18