简体   繁体   English

Extjs 3.4将按钮(编辑,删除)添加到网格行

[英]Extjs 3.4 add buttons (Edit, Delete) to the grid row

I have Grid, in each row must be a column with edit/delete buttons. 我有网格,在每一行中必须是一列带有编辑/删除按钮的列。 When I click on Edit -it must open the popup window and in this popup window must be a form with object filds from the grid row. 当我单击“编辑”时,它必须打开弹出窗口,并且在此弹出窗口中必须是带有网格行中对象对象的表单。 When I click delete button, it must delete object(row). 当我单击删除按钮时,它必须删除对象(行)。 I can not find simple solution... 我找不到简单的解决方案...

What I did: 我做了什么:

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'
}
]

I have added the buttons in 1-st column, but how can I delete and Edit the rows, i can not get RowIndex to do it. 我已经在第一列中添加了按钮,但是如何删除和编辑行,却无法获得RowIndex来完成。 Please any help with this problem. 请对此问题有任何帮助。

Here is what people usually do: 人们通常会这样做:

  • They create a link/button using the renderer with a specific class like this: 他们使用具有特定类的渲染器创建链接/按钮,如下所示:
  • They use the grid rowclick event and check where the user clicked 他们使用网格rowclick事件并检查用户单击的位置
  • If the user clicked on an item that has the targetted class, bingo :) 如果用户单击具有目标类别的项目,则宾果游戏:)

See the corrected fiddle here: 请在此处查看更正的小提琴:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM