gpt4 book ai didi

javascript - Ext Js Grid,如何在keyup上获取单元格的值?

转载 作者:行者123 更新时间:2023-11-30 15:07:05 25 4
gpt4 key购买 nike

我正在使用 Ext Js v6.2 Grid,在我的应用程序中,我需要在 keyup 上获取单元格的值这是我的代码,我试过了但它没有返回值,请更正我的代码如果我错了,我已经搜索了文档和其他没有帮助的东西。请解决问题。提前致谢。

更新代码

    Ext.define('MisCharge', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', mapping: 'name'},
{name: 'age', mapping: 'age'},
{name: 'marks', mapping: 'marks'}
]

});
}


// Store data
var myData = [
{name: "Container Cost"},
{name: "Packaging Cost "},
{name: "Handling Charges "},
{name: "Service Cost of Buyer "},
{name: "Documentation"},
{name: "Cntry of origin Cert."},
{name: "Royalties"},
{name: "Value of Proceeds"},
{name: "Warranty Services"},
{name: "Seller Obligation"},
{name: "Other Charges"},
];
// Creation of first grid store
var gridStore1 = Ext.create('Ext.data.Store', {
model: 'MisCharge',
data: myData,
});
// Creation of first grid
var gridStore = Ext.create('Ext.grid.Panel', {
cls: 'custom-grid',
id: 'gridId',
store: gridStore1,
stripeRows: true,
width: '100%',
collapsible: false,
enableColumnMove: false,
columnLines: true,
sortableColumns: false,
enableColumnHide: false,
enableColumnResize: false,
enableRowHeightSync: true,
columns:
[{
header: "Charges",
dataIndex: 'name',
id: 'charge',
width: 200,
height: 20,
flex: 1

},
{
editor: {
xtype: 'textfield',
enableKeyEvents: true,
listeners: {
keyup: function (form, e) {
var sel_model = gridStore.getSelectionModel();
var record = sel_model.getSelection()[0];
alert(record);
}
}

},
header: "Rate%",
dataIndex: 'age',
flex: 1,
sortable: true,
height: 20,
hideable: false,
},
{
editor: {
xtype: 'textfield',
// selectOnFocus: true
},
header: "Amount()",
dataIndex: 'marks',
flex: 1,
height: 20,
sortable: true,
}],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})]
});

最佳答案

您需要通过引用 el 元素来添加事件。

editor: {
xtype: 'textfield',
enableKeyEvents: true,
listeners: {
keyup: {
element: 'el',
fn: function (a, b) {
var record = gridStore.getSelectionModel().selected.items[0].data
alert(record);
}
}
}
}

关于javascript - Ext Js Grid,如何在keyup上获取单元格的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45591409/

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