ユーザーが行編集を使用して行を保存するときに、グリッド内のコンボ ボックスの値を取得するのに問題があります。キーを変数に保存するコンボボックスに on select イベントがあります。これはこれを行う正しい方法ですか?
これは私がこれまでに持っているものです
function renderAccountSynch() {
var allCustomer = {!allCustomers};
var accountSyncData = {!accountSyncRecordsJSON};
//model for account sync
Ext.define('accountSyncModel', {
extend: 'Ext.data.Model',
idProperty: 'accountId',
fields: [
{name: 'accountId', type: 'string'},
{name: 'accountName', type: 'string'},
{name: 'customerName', type: 'string'},
{name: 'customerId', type: 'string'},
{name: 'isSynched', type: 'boolean'}
]
});
var store = Ext.create('Ext.data.Store', {
model: 'accountSyncModel',
data: accountSyncData
});
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false,
saveBtnText : "Sync",
cancelBtnText : "Cancel"
});
// create reusable renderer
Ext.util.Format.comboRenderer = function(combo){
return function(value){
var record = combo.findRecord(combo.valueField, value);
return record ? record.get(combo.displayField) : combo.valueNotFoundText;
}
}
// create the combo instance
var combo = new Ext.form.field.ComboBox({
id: 'comboId',
typeAhead: true,
triggerAction: 'all',
selectOnTab: true,
//store:[{!allCustomersOptions}],
store: new Ext.data.Store({
fields: [
{name: 'key',
name: 'label'}
],
data: {!allCustomersOptions}
}),
valueField: 'key',
displayField: 'label',
lazyRender: true,
listClass: 'x-combo-list-small'
});
var grid = Ext.create('Ext.grid.Panel', {
height: 450,
forcefit: true,
frame: true,
title: 'Customer Sync',
renderTo: 'syncCustomersId',
store: store,
plugins: [rowEditing],
columns: [{
header: 'Account Name',
width: 100,
flex: 1,
sortable: true,
dataIndex: 'accountName'
},
{
header: 'Customer Name',
dataIndex: 'customerName',
width: 100,
flex: 1,
editor: combo
},
{
xtype: 'checkcolumn',
header: 'Synched',
processEvent: function () { return false; },
dataIndex: 'isSynched',
width: 55
}
],
}
);//end grid creation
//this event fires when a row in the grid has been updated and saved
grid.on('edit', function(editor, e) {
//call save data function which saves the record to SF
syncData(e.record);
});
combo.on('select',function(combo, records) {
Ext.Msg.alert(records[0].get('key'));
selectedComboValue = records[0].get('key')
});
}
var selectedComboValue;
function syncData( record, combo){
var accountId = record.get('accountId');
var customerId = selectedComboValue; // record.get('label');
console.log('--> aocountId = ' + accountId + ' customerId = ' + selectedComboValue );
RenderAdminController.syncAccount(
accountId, customerId,
//callback function
function(result, event) {
if(event.status) {
record.set('isSynched', true);
record.commit();
} else {
//Error
Ext.Msg.alert('Error ' + event.message);
}
},
{
escape : true
}
);
}