我有网格,每行必须有一列带有编辑/删除按钮。当我单击“编辑”时,它必须打开弹出窗口,并且在此弹出窗口中必须有一个包含网格行中的对象字段的表单。当我单击删除按钮时,它必须删除对象(行)。我找不到简单的解决方案...
我做了什么:
columns: [
{
header: 'Action',
width: 145,
sortable: false,
renderer: function (value, metaData, record, rowIndex, colIndex, store) {
function createGridButton(value, id, record, handlerFunc, rowIndex) {
new Ext.Button({
text: value,
value: rowIndex,
handler: handlerFunc
}).render(document.body, id);
}
var id = 'x-btn-container-' + rowIndex;
createGridButton.defer(1, this, ['Edit', id, record, function (btn, e) {
openWindowWithForm();
}, rowIndex]);
createGridButton.defer(2, this, ['Delete', id, record, function (btn, e) {
alert('Row was deleted');
}, rowIndex]);
return ('<div id="' + id + '"></div>');
},
dataIndex: 'action'
},
{
header: 'Login',
dataIndex: 'login'
},
{
header: 'Email',
dataIndex: 'email'
},
{
header: 'FirtsName',
dataIndex: 'firstName'
},
{
header: 'LastName',
dataIndex: 'lastName'
},
{
header: 'Birthday',
dataIndex: 'birthday',
xtype: 'datecolumn',
format: 'd/m/Y'
}
]
我已经在第一列中添加了按钮,但是如何删除和编辑行,我无法让 RowIndex 来执行此操作。 请帮助解决这个问题。
最佳答案
人们通常这样做:
- 他们使用具有特定类的渲染器创建链接/按钮,如下所示:
- 他们使用网格
rowclick
事件并检查用户点击的位置 - 如果用户点击了具有目标类别的项目,宾果游戏:)
在此处查看更正后的 fiddle :
关于javascript - Extjs 3.4向网格行添加按钮(编辑、删除),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25096010/