【问题标题】:ExtJS - Open tab through clicking on link in GridPanel (column renderer)ExtJS - 通过单击 GridPanel(列渲染器)中的链接打开选项卡
【发布时间】:2011-05-02 12:28:18
【问题描述】:

我在网格面板中创建了链接,因此当我单击该链接时,它将在选项卡面板中打开另一个选项卡。目前,我使用 onClick 事件将列单元格输出呈现为 html href。但是渲染器方法openrender()调用另一个方法newtab()似乎出错了,显示错误函数newtab()不能被发现。可能是因为 onClick 事件只能调用 "Ext.onReady(function(){" 块之外的方法/函数?有人吗?知道解决方案,非常感谢任何帮助。

或者,如果您有其他实现相同目的的方法,也可以随时分享。谢谢。


function newtab(state,ptt,status){
    tabs.add({
        title: 'Order List Detail',
                iconCls: 'tabs',
                items: [
                new Ext.Panel({
                    height: 40,
                    html: 'some html'
                })
                ,layout: 'fit'
        }).show();

}

function openrender(value, p, record){
    return String.format('<a <href="#" onClick="newtab(\'{1}\',\'{2}\',\'{3}\')">{0}</a></b>',value, record.data.state, record.data.ptt, 'Open');
}

var grid = new Ext.grid.GridPanel({
frame:true,
title: 'Pending Orders',
layout: 'fit',
store: catstore,
stripeRows: true,
loadMask: true,
iconCls: 'grid',
tbar: [{
        text: 'Category',
        xtype: 'label'
    }
],
columns: [
{header: "State Name", dataIndex: 'state', sortable: true},
{header: "PTT Name", dataIndex: 'ptt', sortable: true},
{header: "Open", dataIndex: 'openstatus', sortable: true, renderer: openrender}
]
});

【问题讨论】:

    标签: hyperlink extjs grid listener renderer


    【解决方案1】:

    我刚刚发现了另一种解决方法,方法是使用网格 cellclick 侦听器

    
    
    

    var grid = new Ext.grid.GridPanel({ frame:true, title: 'Pending Orders', layout: 'fit', store: catstore, stripeRows: true, loadMask: true, iconCls: 'grid', tbar: [{ text: 'Category', xtype: 'label' } ], columns: [ {header: "State Name", dataIndex: 'state', sortable: true}, {header: "PTT Name", dataIndex: 'ptt', sortable: true}, {header: "Open", dataIndex: 'openstatus', sortable: true, renderer: openrender} ], listeners:{ cellclick: function(grid, rowIndex, columnIndex) { // Get the Record for the row var record = grid.getStore().getAt(rowIndex); // Get field name for the column var fieldName = grid.getColumnModel().getDataIndex(columnIndex);

    if(fieldName == 'openstatus') newtab(record.data.state, record.data.ptt, 'Open'); } } });

    【讨论】:

      猜你喜欢
      • 2016-01-15
      • 2019-01-11
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-29
      相关资源
      最近更新 更多