Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Ext.按钮添加到ExtJS columnmodel_Extjs_Extjs3_Extjs Grid - Fatal编程技术网

将Ext.按钮添加到ExtJS columnmodel

将Ext.按钮添加到ExtJS columnmodel,extjs,extjs3,extjs-grid,Extjs,Extjs3,Extjs Grid,我正在创建Ext.grid.GridPanel。我正在尝试将带有xtype:button的列添加到列模型中。我不确定我是否能做到。下面是我的代码,也是到JSFIDLE的链接 我正在使用extjs3.4 Ext.onReady(function () { var myData = [[ 'Lisa', "lisa@simpsons.com", "555-111-1224"], [ 'Bart', "bart@simpsons.com", "555-222-123

我正在创建Ext.grid.GridPanel。我正在尝试将带有
xtype:button
的列添加到列模型中。我不确定我是否能做到。下面是我的代码,也是到JSFIDLE的链接

我正在使用extjs3.4

Ext.onReady(function () {
  var myData = [[ 'Lisa', "lisa@simpsons.com", "555-111-1224"],
                [ 'Bart', "bart@simpsons.com", "555-222-1234"],
                [ 'Homer', "home@simpsons.com", "555-222-1244"],
                [ 'Marge', "marge@simpsons.com", "555-222-1254"]];

  var store = new Ext.data.ArrayStore({
    fields:[ {
      name: 'name'
    },
    {
      name: 'email'
    },
    {
      name: 'phone'
    }],
    data: myData
  });
  var grid = new Ext.grid.GridPanel({
    renderTo: 'grid-container',
    columns:[ {
      header: 'Name',
      dataIndex: 'name'
    },
    {
      header: 'Email',
      dataIndex: 'email'
    },
    {
      header: 'Phone',
      dataIndex: 'phone'
    },
    {
        header: 'action',
        xtype: 'actioncolumn',
        iconCls: 'delete-icon'
        text: 'Delete',
        name: 'deleteBtn',
        handler: function(grid, rowIndex, colIndex, item, e) {
            alert('deleted');
        }      
    },             

    //////////////////////////////
    //I cannot add this column
    {
        header: 'action',
        xtype: 'button',
        text: 'update',
        name: 'btnSubmit'
    }
    ],
    store: store,
    frame: true,
    height: 240,
    width: 500,
    title: 'Framed with Row Selection',
    iconCls: 'icon-grid',
    sm: new Ext.grid.RowSelectionModel({
      singleSelect: true
    })
  });
});

不能像那样将按钮用作列。我们使用以下用户体验来实现您的要求。不幸的是,这是针对ExtJS 4.1的:


您可以尝试使用网格。

您是否可以尝试将此作为您的actioncolumn

{
    xtype: 'actioncolumn',
    width: 50,
    items: 
    [
        {
            icon: 'app/resources/images/cog_edit.png', // Use a URL in the icon config
            tooltip: 'Edit',
            handler: function (grid, rowIndex, colIndex) {
                var rec = grid.getStore().getAt(rowIndex);
                alert("Edit " + rec.get('name'));
            }
        }, 
        {
            icon: 'app/resources/images/delete.png',
            tooltip: 'Delete',
            handler: function (grid, rowIndex, colIndex) {
                var rec = grid.getStore().getAt(rowIndex);
                alert("Terminate " + rec.get('name'));
            }
        }
    ]
}

或者,您可以尝试使用此插件进行删除。您正在使用一个
actioncolumn
作为删除“按钮”。为什么不将它也用于提交按钮呢?actioncolumn用于测试xtype。谢谢。我发现了这个,所以我修改了我的代码,你可以看看这里。它似乎膨胀了。但按钮现在在那里,你有解决办法吗?如果是这样,请把修改后的代码放在这里,并接受它作为答案。因此,深入研究公认的答案将是有益的。