Author Topic: 'wdCenter' of undefined  (Read 1853 times)

adam

  • Newbie
  • *
  • Posts: 1
    • View Profile
'wdCenter' of undefined
« on: January 21, 2022, 06:34:33 am »
Hi,

  there is an error while refreshing after the onWindowResize() event is called.
->'Uncaught TypeError: Cannot read property 'wdCenter' of undefined' error is called.

Uncaught TypeError: Cannot read property 'wdCenter' of undefined
    at pq.cRenderBody.refreshColumnWidths

Could you tell me if this is a bug or I'm doing something wrong?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: 'wdCenter' of undefined
« Reply #1 on: January 21, 2022, 11:14:17 am »
Mentioned error is not reproducible so kindly share a jsfiddle so that it can be looked into.

ronrosell

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: 'wdCenter' of undefined
« Reply #2 on: March 11, 2022, 12:16:32 am »
A number of people have reported this error, and I ran into it myself.

After a series of tests, looking at issues like the presence of tables in iframes and so on, I finally tracked down the culprit (at least in my case): 

I was putting multiple tables into jQuery tabs on the page, using the jQuery UI function described here: https://jqueryui.com/tabs/

Having multiple tables on a page in these jQuery tabs in some way triggers the "wdCenter" error.  Simply removing those tabs makes the error go away.  Most likely, Paramquery is using this jQuery UI function for its tabbed tables. (That approach might work for some ... letting Paramquery handle the tabs ... but in our case some of the tabs on the page don't contain tables.)

The solution is using a different approach to setting up page tabs without using that jQuery UI function (there are a number of other ways to accomplish the same UI effect.)

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: 'wdCenter' of undefined
« Reply #3 on: March 14, 2022, 08:13:16 am »
Hi ronrosell

Thanks for your detailed feedback. ParamQuery doesn't use jQueryUI tabs for its inbuilt tabs UI.

To get rid of the error, please ensure to call refresh on the grids whenever corresponding jQueryUI tab is activated.

Example of Pqgrid in jQueryUI tab: https://paramquery.com/pro/demos/tabs

Code: [Select]
$("#tabs").tabs({
            activate: function (evt, ui) {         
                ui.newPanel.find(".pq-grid").pqGrid( 'refresh' );
            }
});

ronrosell

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: 'wdCenter' of undefined
« Reply #4 on: March 14, 2022, 12:18:13 pm »
Thanks for the suggestion Paramvir,

Just to be sure that I understand the mechanism at work here, does this mean that the table doesn't render if it's loaded into a DIV (or, in our case, an iframe within a DIV) that's not visible (css display:none), hence the need to call refresh?

Ron


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: 'wdCenter' of undefined
« Reply #5 on: March 15, 2022, 08:26:13 am »
Hi Ron

You got it right. If grid's parent / ancestor is hidden or display:none, then grid table doesn't render. It needs to be refreshed when its state transitions from hidden to visible.

Auto detection of change in visibility state and auto refresh might be added in upcoming versions of pqgrid but till then it has to be done manually.

ronrosell

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: 'wdCenter' of undefined
« Reply #6 on: March 17, 2022, 05:08:35 am »
Makes sense, and it's easy enough to work within that constraint. Thank you Paramvir!  You've got a great product here.