ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on October 14, 2016, 07:27:09 pm
-
Hi
Is it possible to call the function in a listener?
Ex:
{
type: 'button',
label: 'test',
icon: 'icon',
listener: function () {
alert('test')
}
-
yes!
-
Great, could you please explain what the syntax would be to call it? 8)
Thanks.
-
Please read the documentation on toolbar ( API and examples ). There are couple of examples:
Syntax for calling any method of grid is:
this.method_name( parameters );
Example:
type:'button',
label: 'Toggle filter row',
listener: function(){
this.option('filterModel.header', !this.option('filterModel.header'));
this.refresh();
}
Live example:
http://paramquery.com/pro/demos/filter_header_local
API reference:
http://paramquery.com/pro/api#option-toolbar
-
Thanks for answer, I'm not sure I understand though.
What I would like to do is to reuse the function code I have in the listener somwhere else on the page by calling the function, is it possible even though it doesn't have a name?
-
In that case it has to be named function.
listener: toggleRow
function toggleRow(){
this.option('filterModel.header', !this.option('filterModel.header'));
this.refresh();
};
Syntax to call that function externally. Note that it requires to set the context of the function:
toggleRow.call( $grid.pqGrid('instance') );
-
Similar question: http://paramquery.com/forum/index.php?topic=1836.0