Author Topic: Inheritance for cVirtual  (Read 841 times)

jplevene

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 138
    • View Profile
Inheritance for cVirtual
« on: January 03, 2025, 07:27:21 pm »
I want to override functions calcTopBottom, getTop, getLeft, etc. which is in  window.pq.cVirtual.

I am using the jQuery version of pqGid, so to overwrite some functions I use the following which works fine:

Code: [Select]
(function($) {
var fn = $.paramquery._pqGrid.prototype;
fn.showLoading = function() {
if(this.$grid_center.is(":visible"))
{
this.loading = true;
open_loading_overlay();
}
};
fn.hideLoading = function() {
this.loading = false;
close_loading_overlay();
};
})(jQuery);

However when I want to override cVirtual functions, to test this I do the following:

Code: [Select]
var cVirtual = window.pq.cVirtual.prototype;
cVirtual.calcTopBottom = function(left) {
console.log("calcTopBottom");
// Call the old
return cVirtual.calcTopBottom(left);
};
cVirtual.getTop = function(ri, actual) {
console.log("getTop");
// Call the old
return cVirtual.getTop(ri, actual);
};
cVirtual.getLeft = function(ci, actual) {
console.log("getLeft");
// Call the old
return cVirtual.getLeft(ci, actual);
};
cVirtual.getHeightR = function(ri, rows) {
console.log("getHeightR");
// Call the old
return cVirtual.getHeightR(ri, rows);
};
cVirtual.calInitFinal = function(top, bottom, left) {
console.log("calInitFinal");
// Call the old
return cVirtual.calInitFinal(top, bottom, left);
};

However the above functions are never called.  What am I doing wrong?

jplevene

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 138
    • View Profile
Re: Inheritance for cVirtual
« Reply #1 on: January 13, 2025, 11:33:29 pm »
Please can you respond to this support request

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6344
    • View Profile
Re: Inheritance for cVirtual
« Reply #2 on: January 14, 2025, 12:47:11 pm »
Glad to help however customization of ParamQuery internals is outside the scope of support.

cVirtual works as mixin object for other objects, hence overriding its methods doesn't work.