This topic is locked
[SOLVED]

 slow pageObj.hidefield in Javascript

9/9/2019 2:02:01 AM
PHPRunner General questions
A
AndrewMark author

I have the below code in Javascript onload on an addpage with lots of hidefields.
I am finding loading to be very slow whenever a pageobj.hidefield is involved. eg per below if ctrlperiod1 == yes it takes ages for the BSCheckExpl,BSCheckDesc,Fin1stPeriodExpl to hide .
I am not having this problem on the showfields though.
I was wondering if anybody else had experienced this and had ideas to speed this up.
pageObj.hideField("BSCheckExpl");

pageObj.hideField("BSCheckExpl2");

pageObj.hideField("BSCheckExpl3");

pageObj.hideField("BSCheckDesc");

pageObj.hideField("BSCheckDesc2");

pageObj.hideField("BSCheckDesc3");

pageObj.hideField("Fin1stPeriodExpl");

pageObj.hideField("Fin2ndPeriodExpl");

pageObj.hideField("Fin3rdPeriodExpl");
var ctrlperiod1 = Runner.getControl(pageid, 'Fin1stPeriod');

ctrlperiod1.on('change', function(e) {

if (this.getValue() == 'yes') {

pageObj.hideField("BSCheckExpl");

pageObj.hideField("BSCheckDesc");

pageObj.hideField("Fin1stPeriodExpl");

}

if (this.getValue() == 'no') {

pageObj.showField("Fin1stPeriodExpl");

if(ctrlbalsheetcheck.getValue()==0){

pageObj.hideField("BSCheckExpl");

pageObj.hideField("BSCheckDesc");

}

else{

var BSCheckDesc = "Balance sheet is out of balance by $" + ctrlbalsheetcheck.getValue();

var ctrlBSCheckDesc = Runner.getControl(pageid, 'BSCheckDesc');

ctrlBSCheckDesc.setValue(BSCheckDesc);

pageObj.showField("BSCheckExpl");

pageObj.showField("BSCheckDesc");

}

}

});

woodey2002 9/9/2019

Many thanks to Sergey for pointing this out to me some time back..
Try this...there are too many controls on that page and hiding those is not that fast. The easy workaround though is to hide those controls that you need to hide initially in PHP code. Those that you show/hide dynamically need to stay in Javascript event of course. But, for instance, hiding the controls in BeforeDisplay event will speed up your page significantly.
Below is the code for BeforeDisplay event. Also remove the code that initially hides controls from Javascript OnLoad events, only leave the dynamic part there.
$pageObject->hideField("BSCheckExpl");

$pageObject->hideField("BSCheckExpl2");

$pageObject->hideField("BSCheckExpl3");

A
AndrewMark author 9/9/2019



Many thanks to Sergey for pointing this out to me some time back..
Try this...there are too many controls on that page and hiding those is not that fast. The easy workaround though is to hide those controls that you need to hide initially in PHP code. Those that you show/hide dynamically need to stay in Javascript event of course. But, for instance, hiding the controls in BeforeDisplay event will speed up your page significantly.
Below is the code for BeforeDisplay event. Also remove the code that initially hides controls from Javascript OnLoad events, only leave the dynamic part there.
$pageObject->hideField("BSCheckExpl");

$pageObject->hideField("BSCheckExpl2");

$pageObject->hideField("BSCheckExpl3");



Wow, that sped it up a lot - thanks