ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: Robert on April 23, 2014, 01:45:12 am
-
I have 2 grids in separate <div>'s but in one php page.
Both grids are working perfectly HOWEVER, I would like to call a function in one of the grids from the other one (and pass in a var). Because they are wrapped in self executing functions, I cannot access the internal function of the opposite grid.
Is it possible to call an internal function of one grid from another grid?
Thanks in advance!
-
After miles of searching before asking the question here ... I didn't realize how close I was to the answer. My apologies. I found an example that allows this to happen and it works beautifully.
(function($) {
var namespace;
namespace = {
something : function() {
alert('hello there!');
},
bodyInfo : function() {
alert($('body').attr('id'));
}
};
window.ns = namespace;
})(this.jQuery);
$(function() {
ns.something();
ns.bodyInfo();
});
-
Common solution to this is:
If you want to call API of a grid for which you don't have its instance variable, you can always get reference to it using the selector.
$(function(){
//grid A constructed in this function.
var obj = {....};
var $gridA = $("#A").pqGrid( obj );
});
$(function(){
var $gridA = $("#A");
//call methods
$gridA.pqGrid( 'some method' );
});
-
Fantastic suggestion! THANK YOU!!! I will work with this and see if it solves what appears to be a scope issue I am having. Thank you again.
-
This seems so simple but I am having issues getting this to work. Is there and example I can see where this is implemented?
-
OH MY ... I got it to work!!! You are a life saver!!!