iteye_9116 2010-10-27 11:54
浏览 845
已采纳

XTemplate 事件问题

[b]我想要在XTtemplate中添加一个链接的单击事件,当点击链接在同一页面的另一个Panel中显示数据并重新加载,请问怎么做呀?[/b]
[color=blue]XTtemplate中自带的事件不行,因为它在进入页面时就加载了,我要点击之后才加载。[/color]
下面的我的[b]ExtJS代码[/b]:
createFlowConsole : function() {
var data = ['actionId','name'];
this.store = new Ext.data.JsonStore({
url: _ctx.base + '/osworkeflow/getAvailableActions.action',
root:'action',
fields: data
});

    var xtpl = new Ext.XTemplate(
        '<tpl for=".">',
            '<tpl if="xindex % 2 == 1">',
                '<div class="x-grid3-cell-inner" style="font-size:10px; background-color:#FFFFFF; border-bottom:1px solid #EDEDED"">',
                '<span class="" style=" padding-left:30px;"><a id="showMySteps" href="javaScript: onclick={[this.test()]}">{name}</a></span></div>',
            '</tpl>',
            '<tpl if="xindex % 2 == 0">',
                '<div class="x-grid3-cell-inner" style="font-size:10px; background-color:#FAFAFA; border-bottom:1px solid #EDEDED"">',
                '<span class="" style=" padding-left:30px;"><a href="#">{name}</a></span></div>',
            '</tpl>',
        '</tpl>',{
            test : function(){
                alert("ok");
            }
        }
    );  

    this.availableActionsPanel = new Ext.Panel( {
        id : 'mySteps_panel',
        region : 'north',
        title : '我的步骤',
        margins : '0 0 5 0',
        height : 150,
        items: new Ext.DataView({
            store: this.store,
            tpl: xtpl,
            autoHeight:true,
            multiSelect: true,
            overClass:'x-view-over',
            itemSelector:'div.thumb-wrap',
            emptyText: 'No data to display'
        })
    });

    this.steps = this.createSetpsGrid();

    var flowConsole = new Ext.Panel( {
        region : 'center',
        layout : "border",
        border : false,
        items : [ this.availableActionsPanel, this.steps ],
        margins : '5 5 5 0'
    });
    return flowConsole;
}

详细如下附件图所示 :

  • 写回答

2条回答 默认 最新

  • lizhiyezi 2010-10-27 13:44
    关注

    我吧测试代码给你瞧吧。应该是你哪里写错了,不然不会出现你说的情况
    [code="java"]
    function test() {
    alert('onclick');
    }
    Ext.onReady(function() {
    this.store = new Ext.data.JsonStore({
    data : [{
    name : 'aaa'
    }],
    fields : ['name']
    });
    // window.test = function() {
    // alert('onclick');
    // }
    var xtpl = new Ext.XTemplate(
    '',
    '',
    '

    ',
    '{name}
    ',
    '',
    '',
    '
    ',
    '{name}
    ',
    '', '');

    this.availableActionsPanel = new Ext.Panel({
                id : 'mySteps_panel',
                region : 'north',
                title : '我的步骤',
                margins : '0 0 5 0',
                height : 150,
                items : new Ext.DataView({
                            store : this.store,
                            tpl : xtpl,
                            autoHeight : true,
                            multiSelect : true,
                            overClass : 'x-view-over',
                            itemSelector : 'div.thumb-wrap',
                            emptyText : 'No data to display'
                        })
            });
    var win = new Ext.Window({
                width : 500,
                height : 200,
                layout : 'fit',
                items : this.availableActionsPanel
            })
    win.show();
    

    })[/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?