在我的Extjs4應用程序中,我有一個網格和一個表單。Extjs 4,帶複選框和加載記錄的表單
用戶模型:
Ext.define('TestApplication.model.User', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int', useNull: true },
{ name: 'email', type: 'string'},
{ name: 'name', type: 'string'},
{ name: 'surname', type: 'string'}
],
hasMany: { model: 'Agency', name: 'agencies' },
});
和原子能機構:
Ext.define('Magellano.model.Agency', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int', useNull: true},
{name: 'name', type: 'string'}
]
});
然後在我的形式,我創建的複選框:
[...]
initComponent: function() {
var store = Ext.getStore('Agencies');
var checkbox_values = {xtype: 'checkboxfield', name: 'agencies[]'};
var checkboxes = []
store.each(function(record){
var checkbox = {xtype: 'checkboxfield', name: 'agency_ids',
boxLabel: record.get('name'), inputValue: record.get('id')};
checkbox.checked = true;
checkboxes.push(checkbox)
});
this.items = [{
title: 'User',
xtype: 'fieldset',
flex: 1,
margin: '0 5 0 0',
items: [{
{ xtype: 'textfield', name: 'email', fieldLabel: 'Email' },
{ xtype: 'textfield', name: 'name', fieldLabel: 'Nome' },
}, {
title: 'Agencies',
xtype: 'fieldset',
flex: 1,
items: checkboxes
}];
[...]
一切行之有效的形式發送我正在接收所有數據並可將其保存到數據庫中。
當用戶點擊記錄與標準的形式加載的網格:
form.loadRecord(record);
的問題是,複選框不檢查。複選框元素是否有任何命名約定,Extjs可以檢測到要設置的內容?我如何設置關係,以便表單理解要檢查的內容?還是我應該手工做所有事情?
我加入這個PARAMS到複選框,但沒有更改...表單上的複選框有什麼問題? – efirat
我的問題是我正在使用xtype:'textfield'和inputType:'checkbox',它似乎可以正常工作,但是直到我改變了xtype才正常工作。謝謝 –