如何从extjs中的控制器调用方法 [英] How to call a method from controller in extjs

查看:185
本文介绍了如何从extjs中的控制器调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个柱状柱形图..我想当我单击该柱形时,将显示它的值并调用另一个函数,在该函数中我将通过ajax调用数据库.

I have a bar column chart.. I want when I click on the column then the value of it will be shown and call another function where i will call the database thru ajax.

当我单击列时,将显示该值,但第二部分(即第二个函数调用)未完成. 这是我的控制器代码...

When I click on the column the value is shown but the 2nd part i.e. the 2nd function call is not done.. here is my controller code...

initializedEvents: false,
init: function() {
    this.control({
        '#barColumnChart': {
            afterlayout: this.afterChartLayout
        }
    });
},
afterChartLayout: function(){
    if(this.initializedEvents==true) return;
    this.initializedEvents=true;
    Ext.getCmp('barColumnChart').series.items[0].on('itemmousedown',function(obj){
        var barData=obj.storeItem.data['source']+ ' &' + obj.storeItem.data['count'];

            // I want to call the dataBaseCall function here

    });
},
dataBaseCall: function(barData){
    alert(barData);
}

推荐答案

尝试一下

afterChartLayout: function(){
    var me = this;
    if(this.initializedEvents==true) return;
    this.initializedEvents=true;
    Ext.getCmp('barColumnChart').series.items[0].on('itemmousedown',function(obj){
        var barData=obj.storeItem.data['source']+ ' &' + obj.storeItem.data['count'];

            me.dataBaseCall(barDat);

    });
},
dataBaseCall: function(barData){
    alert(barData);
}

您也可以将控制器作用域添加到事件中,但是我个人更喜欢这样做.

You can also add the controller scope to the event but I personally prefer this.

这篇关于如何从extjs中的控制器调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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