2015-07-20 39 views
0

以下是我在特定列的每个单元格中创建下载链接的代码。这也工作得很好..但在下面的代码中,我使用它只允许下载链接的图标。任何人都可以请帮助我如何为列的每个单元格创建一个按钮而不是图标。如何在网格中的特定列的每个单元格中创建按钮 - EXT JS

this.columns = [ { 
      text : 'documentName', 
      dataIndex : 'documentName', 
      flex : 1.5, 
      sortable : true 
     }, { 
      text : 'documentDescription', 
      dataIndex : 'documentDescription', 
      flex : 2.5, 
      sortable : true 
     }, 
    { text : 'downloadLink',, 
      xtype:'actioncolumn', 
      flex : 0.5,   
      items: [{ 
       icon: 'staticfiles/download.png', // Use a URL in the icon config 
       iconCls:'downloadHelpDocIcon', 
       tooltip: 'Download',    
       handler: function(grid, rowIndex, colIndex) { 
        var rec = grid.getStore().getAt(rowIndex); 
        //alert("Edit " + rec.get('downloadLink')); 

       } 
      }] 
     } 

回答

0

只需添加一个按钮的物品数组:

text: 'column2', 
dataIndex: 'column2', 
items: [{ 
    xtype: 'button', 
    text: 'click', 
    ... 
}] 
+0

呀......我试试这个..这却与此列标题,所有单元格值该列显示了下方的按钮实际的内容而不是按钮。 – Kumar

+0

这已解决..下面是我用过的代码。 { \t \t \t的xtype: 'componentcolumn', \t \t \t文字: '下载链接', 软硬度:0.5, \t \t \t排序:假的, \t \t \t dataIndex: 'downloadLink',\t \t \t \t \t \t \t \t \t \t \t \t渲染:函数(值,元,备案){ \t \t \t \t \t \t \t \t回{\t \t \t \t \t \t \t \t \t \t的xtype: '按钮', \t \t \t \t \t文本:下载', \t \t \t \t名\t听众:{ \t \t \t \t \t \t点击:功能(场,E){ \t \t \t \t \t \t \t警报( '点击'); \t \t \t \t \t \t} \t \t \t \t \t} \t \t \t \t}; \t \t \t \t \t \t \t} \t \t \t \t \t \t \t} – Kumar

+0

对不起,我完全误解了你的问题。我以为你想在标题中的按钮。你在哪个版本上?你可能想看看这个: http://docs.sencha.com/extjs/6.0/6.0.0-classic/#!/api/Ext.grid.column.Widget – Tarabass

相关问题