[英]Extjs 3.4 add buttons (Edit, Delete) to the grid row
我有網格,在每一行中必須是一列帶有編輯/刪除按鈕的列。 當我單擊“編輯”時,它必須打開彈出窗口,並且在此彈出窗口中必須是帶有網格行中對象對象的表單。 當我單擊刪除按鈕時,它必須刪除對象(行)。 我找不到簡單的解決方案...
我做了什么:
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
事件並檢查用戶單擊的位置 請在此處查看更正的小提琴:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.