extjs - 将 Ext.Button 添加到 ExtJS columnmodel

标签 extjs extjs3 extjs-grid

我正在创建一个 Ext.grid.GridPanel。我正在尝试将带有 xtype: button 的列添加到列模型中。我不确定,如果我能做到这一点。下面是我的代码,也是 jsfiddle http://jsfiddle.net/bXUtQ/ 的链接

我正在使用 extjs 3.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
    })
  });
});

最佳答案

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

http://www.sencha.com/forum/showthread.php?148064-Component-Column-Components-in-Grid-Cells

关于extjs - 将 Ext.Button 添加到 ExtJS columnmodel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15389739/

相关文章:

javascript - 网格中的最后一列需要自定义标题

javascript - ExtJS 和 Internet Explorer : Layout corruption with scrollbars

extjs - Colspan 不合并 Extjs 表布局中的列

javascript - ExtJs 3.2.1 将 CSS 边距应用于组合框

javascript - 动态添加文本区域到容器extjs

javascript - 在 Extjs grid On options select from combo box 中,它从网格中删除所有记录的选择

android - 如何使用senchatouch 2在android中实现phonegap应用

ExtJS4 - 如何在选择更改时获取父网格?

extjs3 - EXTjs 面板折叠和展开方法

checkbox - 在网格列 ExtJs 中的一行中显示一组复选框