如何调用该的onclick javascript函数在我的建筑 [英] How to call this onclick javascript function in my architecture

查看:313
本文介绍了如何调用该的onclick javascript函数在我的建筑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用本文架构 HTTP: //blog.extjs.eu/know-how/writing-a-big-application-in-ext/

在我的一类Dashboardgrid我有两个功能是:

 ,linkRenderer:功能(数据,单元格,记录和rowIndex,参数:columnIndex,存储){
        如果(数据!= NULL){
            回归'< A HREF =JavaScript的:无效(0)的onclick =this.resellerwindow(\\''+ record.data.cityname +\\')>'+数据+'< / A>';
        }
        返回的数据;
    },
    resellerwindow:功能(城市名){
        //呈现网格在页面指定的div
        // resellergrid.render();
        resellerstore.load();
        wingrid.show(本);
    }

在linkrendrer功能的Click事件被称为它给误差

  this.resellerwindow不是一个函数

在这里,我应该怎么把resellerwindow功能?

我ResellerDashBoard类

  Application.DashBoardGrid = Ext.extend(Ext.grid.GridPanel,{
     边框:假的
    ,initComponent:功能(){
        无功配置= {
            店:新Ext.data.JsonStore的实践例子({
                //商店CONFIGS
                autoDestroy:真实,
                自动加载:真,
                网址:'?API / index.php的_command = getresellerscount',
                STOREID:getresellerscount',
                //读者CONFIGS
                根:cityarray',
                idProperty:城市名,
                领域:
                    {名称:城市名},
                    {名称:'totfollowup},
                    {名称:'totcallback},
                    {名称:'totnotintrested},
                    {名称:'totdealsclosed},
                    {名称:'totcallsreceived},
                    {名称:'totcallsentered},
                    {名称:'totresellerregistered},
                    {名称:'countiro},
                    {名称:'irotransferred},
                    {名称:'irodeferred'}
                ]
            })
            ,列: [
                {
                    ID:城市名,
                    标题:城市名称,
                    宽度:120,
                    排序:真实,
                    dataIndex:城市名
                },
                {
                    ID:'countiro',
                    标题:总展望,
                    宽度:100,
                    排序:真实,
                    dataIndex:'countiro
                },
                 {
                    ID:'irotransferred',
                    标题:呼叫转移到税务条例,
                    高度:50,
                    宽度:100,
                    排序:真实,
                    dataIndex:'irotransferred
                },
                {
                    ID:'irodeferred',
                    标题:呼叫延迟到税务条例,
                    宽度:100,
                    排序:真实,
                    dataIndex:'irodeferred
                },
                {
                    ID:'totcallsentered',
                    标题:呼叫总数进入'
                    宽度:100,
                    排序:真实,
                    dataIndex:'totcallsentered',
                    渲染:this.linkRenderer
                },
                {
                    ID:'totfollowup',
                    标题:'跟进',
                    宽度:100,
                    排序:真实,
                    dataIndex:'totfollowup
                },
                {
                    ID:'totcallback',
                    标题:'回调',
                    宽度:100,
                    排序:真实,
                    dataIndex:'totcallback
                },
                {
                    ID:'totnotintrested',
                    头:不感兴趣,
                    宽度:100,
                    排序:真实,
                    dataIndex:'totnotintrested
                },
                {
                    ID:'totdealsclosed',
                    标题:交易完成,
                    宽度:100,
                    排序:真实,
                    dataIndex:'totdealsclosed
                },
                 {
                    ID:'totresellerregistered',
                    标题:经销商注册',
                    宽度:100,
                    排序:真实,
                    dataIndex:'totresellerregistered
                }
            ]
          ,插件:[]
          ,viewConfig:{forceFit:真正}
          ,TBAR:[]
          ,BBAR:[]
          ,身高:350
          ,宽:1060
           ,标题:经销商控制台        }; // EO配置对象        //应用配置
        Ext.apply(这一点,Ext.apply(this.initialConfig,配置));        Application.DashBoardGrid.superclass.initComponent.apply(这一点,参数);
    } // EO功能initComponent
    / **
    *这是小区的链路的渲染
    *电池的@参数数据值
    *数据记录@param对象存储的所有数据和record.id是独一无二的
    ** /
    ,linkRenderer:功能(数据,单元格,记录和rowIndex,参数:columnIndex,存储){
        如果(数据!= NULL){
            回归'< A HREF =JavaScript的:无效(0)的onclick =DashBoardGrid.resellerwindow(\\''+ record.data.cityname +\\')>'+数据+'< / A>';
        }
        返回的数据;
    },
    resellerwindow:功能(城市名){
        //呈现网格在页面指定的div
        // resellergrid.render();
        resellerstore.load();
        wingrid.show(本);    }
    ,OnRender方法:功能(){
        // this.store.load();
        Application.DashBoardGrid.superclass.onRender.apply(这一点,参数);
    } // EO功能的OnRender
});Ext.reg('DashBoardGrid',Application.DashBoardGrid);


解决方案

而不是建设,并通过直接的HTML,尝试这些。


  1. 创建锚对象


  

{标签:'A',
      HREF:'#',
      HTML:按我,
      的onclick:this.resellerWindow}



  1. 确保,范围,linkRenderer是网格,通过设置范围:这个在该列的定义。这样this.resellerWindow是指网格的功能。


  2. 尝试返回创建的对象。


I am using this article of architecture http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/

In my one class of Dashboardgrid i have two functions are :

,linkRenderer : function (data, cell, record, rowIndex, columnIndex, store) {
        if  (data != null)  {
            return '<a href="javascript:void(0)" onclick="this.resellerwindow(\'' +record.data.cityname+'\')">'+ data +'</a>';
        }
        return data;
    },
    resellerwindow : function (cityname) {
        // render the grid to the specified div in the page
        // resellergrid.render();
        resellerstore.load();
        wingrid.show(this);
    } 

when the click event of linkrendrer function is called it gives error

this.resellerwindow is not a function

where and how should i put resellerwindow function ?

My ResellerDashBoard Class

Application.DashBoardGrid = Ext.extend(Ext.grid.GridPanel, {
     border:false
    ,initComponent:function() {
        var config = {
            store:new Ext.data.JsonStore({
                // store configs
                autoDestroy: true,
                autoLoad :true,
                url: 'api/index.php?_command=getresellerscount',
                storeId: 'getresellerscount',
                // reader configs
                root: 'cityarray',
                idProperty: 'cityname',
                fields: [
                    {name: 'cityname'},
                    {name: 'totfollowup'},
                    {name: 'totcallback'},
                    {name: 'totnotintrested'},
                    {name: 'totdealsclosed'},
                    {name: 'totcallsreceived'},
                    {name: 'totcallsentered'},
                    {name: 'totresellerregistered'},
                    {name: 'countiro'},
                    {name: 'irotransferred'},
                    {name: 'irodeferred'}
                ]
            })
            ,columns: [
                {
                    id       :'cityname',
                    header   : 'City Name', 
                    width    : 120, 
                    sortable : true, 
                    dataIndex: 'cityname'
                },
                {
                    id       :'countiro',
                    header   : ' Total Prospect', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'countiro'
                },
                 {
                    id       :'irotransferred',
                    header   : 'Calls Transfered By IRO', 
                    height : 50,
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'irotransferred'
                },
                {
                    id       :'irodeferred',
                    header   : ' Calls Deferred By IRO', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'irodeferred'
                },
                {
                    id       :'totcallsentered',
                    header   : ' Total Calls Entered', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex : 'totcallsentered',
                    renderer : this.linkRenderer
                },
                {
                    id       :'totfollowup',
                    header   : ' Follow Up', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'totfollowup'
                },
                {
                    id       :'totcallback',
                    header   : ' Call Backs', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'totcallback'
                },
                {
                    id       :'totnotintrested',
                    header   : ' Not Interested', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'totnotintrested'
                },
                {
                    id       :'totdealsclosed',
                    header   : ' Deals Closed', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'totdealsclosed'
                },
                 {
                    id       :'totresellerregistered',
                    header   : ' Reseller Registered', 
                    width    : 100, 
                    sortable : true, 
                    dataIndex: 'totresellerregistered'
                }
            ]
          ,plugins :[]
          ,viewConfig :{forceFit:true}
          ,tbar :[]
          ,bbar :[]
          ,height : 350
          ,width : 1060
           ,title : 'Reseller Dashboard'

        }; // eo config object

        // apply config
        Ext.apply(this, Ext.apply(this.initialConfig, config));

        Application.DashBoardGrid.superclass.initComponent.apply(this, arguments);
    } // eo function initComponent
    /** 
    * It is the renderer of the links of cell 
    * @param data  value of cell 
    * @param record  object of data has all the data of store and record.id is unique 
    **/
    ,linkRenderer : function (data, cell, record, rowIndex, columnIndex, store) {
        if  (data != null)  {
            return '<a href="javascript:void(0)" onclick="DashBoardGrid.resellerwindow(\'' +record.data.cityname+'\')">'+ data +'</a>';
        }
        return data;
    },
    resellerwindow : function (cityname) {
        // render the grid to the specified div in the page
        // resellergrid.render();
        resellerstore.load();
        wingrid.show(this);

    }
    ,onRender:function() {
        // this.store.load();
        Application.DashBoardGrid.superclass.onRender.apply(this, arguments);
    } // eo function onRender
});

Ext.reg('DashBoardGrid', Application.DashBoardGrid);

解决方案

instead of building and passing direct html, try these.

  1. Create Anchor object

{ tag: 'a', href: '#', html: 'click me', onclick: this.resellerWindow }

  1. Make sure that, scope in linkRenderer is grid, by settings 'scope: this' in that column definition. So that this.resellerWindow refers to grid's function.

  2. try returning created object.

这篇关于如何调用该的onclick javascript函数在我的建筑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆