Reputation: 3867
When I run form.loadRecord(record);
, datas comes to tetfields but checkbox and combo using id value is empty for all... there are many solutions to this issue I tried but it does not work for me.
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() {}
});
Solution 1:
field: {
xtype: 'checkboxfield',
name: 'active_state',
value: 1,
inputValue: 1,
uncheckedValue: 0
}
or:
field: {
xtype: 'checkboxfield',
name: 'active_state',
value: 1,
inputValue: true,
uncheckedValue: false
}
or:
field: {
xtype: 'checkboxfield',
name: 'active_state',
value: 1,
inputValue: 'true',
uncheckedValue: 'false'
}
Upvotes: 3
Views: 14683
Reputation: 138
When you call the loadRecord, for every field of the record a form field with the same name is searched and if it's found the "setValue" of that record is called so you have to look at that method for checkboxes and combos. For checkboxes it's fairly easy: as default only these values will check your checkbox:
true
'true'
'1'
'on'
while any other value will check it as false. So if the field in your model is defined as type boolean everything works (so maybe you should check that model field and form item name match). If you need a custom "true" value just specify the inputValue property.
For comboboxes it's a bit more complicated if their store is set as remote AND are set as forceSelection true AND value field is different from display field, but in your case there should be no problem at all. I think your problem is that you used ArrayStore, just switch to data store.
Upvotes: 2