ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on November 17, 2016, 01:53:07 pm
-
Hi
I would like to call a function from a listener:
listener: function () {
call function in the create: function part
}
create: function (evt, ui) {
function code
}
How can I do that?
Thanks.
-
Anonymous functions are commonly used in event callbacks, they are not so convenient to be called at will.
Please use following ways:
1. use an initialization object.
//obj is initialization object.
var obj = {
width: "80%",
height: 400,
title: "Grid From JSON",
create: function create(){
alert('create');
},
toolbar: {
items:[
{
type:'button',
label:'call create',
listener: function(){
obj.create.call(this);
}
}
]
},
scrollModel: { autoFit: true },
dataModel: { data: data }
};
2. Abstract the common functionality into a named function and then you can call the functions by their names.
3.
listener: function(){
this.option('create').call(this);
}