gpt4 book ai didi

javascript - 扩展JS 3.4 : Event listener for cell editing

转载 作者:行者123 更新时间:2023-12-03 00:36:49 25 4
gpt4 key购买 nike

我面临使用 Ext Js 3.4 中的单元格编辑器触发编辑事件的问题。

我试图在按'Enter'后编辑的单元格上触发ajax调用。

目前,我只是替换为 console.log('hi'),但在我按 'Enter' 后它没有显示任何内容。

我不确定我的代码有什么问题。如果有人能指出这一点,我们将不胜感激。谢谢。

var grid = new Ext.grid.EditorGridPanel({
store: api_store,
loadMask: true,
clicksToEdit: 1,
tbar: [{
text: 'Create',
handler: function () { }
}],
columns: [
{
id: 'name',
header: 'Key Name',
width: 300,
sortable: true,
dataIndex: 'name',
editor: {
xtype: 'textfield',
allowBlank: false,
listener: {
edit: function (el) {
console.log('hi');
}
}
}
},
{
header: 'Key Value',
width: 500,
sortable: false,
dataIndex: 'key'
}
],
sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
viewConfig: {
forceFit: true
},
height: 210,
stripeRows: true,
height: 350,
title: 'Keys'
});

最佳答案

解决方案:

使用 EditorGridPanel afteredit 事件:

afteredit(e)

Fires after a cell is edited. The edit event object has the following properties

  • grid - This grid
  • record - The record being edited
  • field - The field name being edited
  • value - The value being set
  • originalValue - The original value for the field, before the edit.
  • row - The grid row index
  • column - The grid column index

Parameters:

e : Object An edit event (see above for description)

示例:

Ext.onReady(function () {        

var api_store = new Ext.data.ArrayStore({
fields: ['key', 'name'],
data: [
['1', 'Name1'],
['2', 'Name2'],
['3', 'Name3']
]
});


var grid = new Ext.grid.EditorGridPanel({
renderTo: Ext.getBody(),
store: api_store,
loadMask: true,
clicksToEdit: 1,
tbar: [{
text: 'Create',
handler: function () { }
}],
listeners: {
afteredit: function(e) {
console.log('After edit. Column: ' + e.field);
}
},
columns: [
{
id: 'name',
header: 'Key Name',
width: 300,
sortable: true,
dataIndex: 'name',
editor: {
xtype: 'textfield',
allowBlank: false
}
},
{
header: 'Key Value',
width: 500,
sortable: false,
dataIndex: 'key'
}
],
sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
viewConfig: {
forceFit: true
},
height: 210,
stripeRows: true,
height: 350,
title: 'Keys'
});

});

关于javascript - 扩展JS 3.4 : Event listener for cell editing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53624507/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com