当我运行form.loadRecord(record);
时,数据来到tetfields但是复选框和使用id值的组合对所有人都是空的...我尝试过这个问题有很多解决方案,但它对我不起作用。
Ext.define('Ext.migration.ProductEditPanel', {
extend: 'Ext.panel.Panel',
alias: 'widget.producteditpanel',
title: 'Genel Bilgiler',
layout: 'column',
bodyPadding: 5,
ds_activeProductTypes: this.ds_activeProductTypes,
initComponent: function() {
this.items = [{
columnWidth: 0.5,
xtype: 'form',
id: 'productcrudform',
margin: '0 5 0 0',
bodyPadding: 5,
name: 'productcrudform',
url: baseUrl + "productcrud",
defaultType: 'textfield',
items: [{
scale: this,
inputType: 'hidden',
id: 'actionType',
name: 'actionType',
value: this.actionType
},{
fieldLabel: 'ID',labelWidth: 140,
id: 'id',
name: 'id',
disabled: true,
anchor : '100%'
},{
fieldLabel: 'Ürün Adı',labelWidth: 140, anchor : '100%',
id: 'name',
name: 'name'
},{
fieldLabel: 'Kod', labelWidth: 140, anchor : '100%',
name: 'code',
},
{
xtype : 'combo', labelWidth: 140, anchor : '100%',
fieldLabel : 'Ürün Tipi',
name : 'productType.name',
hiddenName : 'productType.id',
store : new Ext.data.ArrayStore({
fields : [ 'productType.id', 'productType.name'],
data : [
[ 1, 'TISORT'],
[ 2, 'POSTER'],
[ 3, 'KAPSONLU'],
[ 4, 'TELEFON_KAPAK']]
}),
mode : 'local',
valueField : 'productType.id',
displayField : 'productType.name'
},{
fieldLabel: 'Aktif', labelWidth: 140, width: 180,
inputType: 'checkbox',
name: 'activeFlag'
},{
name: 'newFlag',
fieldLabel: 'Yeni Ürün', labelWidth: 140, width: 180,
inputType: 'checkbox'
},{
name: 'clearanceFlag',
fieldLabel: 'Tasfiye Ürün', labelWidth: 140, width: 180, anchor : '0%',
inputType: 'checkbox'
}
]
},
{ // PRICE GRID INIT
columnWidth: 0.5,
title: 'Prices',
requires: 'Ext.migration.PriceGrid',
xtype: 'productpricegrid',
id: 'prices-grid',
region: 'center',
border: true,
store: pricesStore
}];
this.callParent(arguments);
},
onSubmit: function() {}
});
解决方案1:
field: {
xtype: 'checkboxfield',
name: 'active_state',
value: 1,
inputValue: 1,
uncheckedValue: 0
}
或:
field: {
xtype: 'checkboxfield',
name: 'active_state',
value: 1,
inputValue: true,
uncheckedValue: false
}
或:
field: {
xtype: 'checkboxfield',
name: 'active_state',
value: 1,
inputValue: 'true',
uncheckedValue: 'false'
}
答案 0 :(得分:2)
当您调用loadRecord时,对于记录的每个字段,将搜索具有相同名称的表单字段,如果找到该记录的“setValue”,则必须查看该方法的复选框和组合。 对于复选框,它非常简单:默认情况下,只有这些值会检查您的复选框:
true
'true'
'1'
'on'
而任何其他值都会将其检查为false。因此,如果模型中的字段被定义为boolean类型,则一切正常(因此,您可以检查该模型字段和表单项名称是否匹配)。如果需要自定义“true”值,只需指定inputValue属性。
对于组合框,如果将它们的存储设置为远程并且设置为forceSelection true并且值字段与显示字段不同,则它会更复杂,但在您的情况下应该没有任何问题。我认为您的问题是您使用了ArrayStore,只需切换到数据存储。