簡體   English   中英

Extjs 3.4將按鈕(編輯,刪除)添加到網格行

[英]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事件並檢查用戶單擊的位置
  • 如果用戶單擊具有目標類別的項目,則賓果游戲:)

請在此處查看更正的小提琴:

http://jsfiddle.net/bubbliscious/4x8LJ/1/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM