This topic is locked
[SOLVED]

 Dependent dropdown is not working

2/11/2020 7:04:48 PM
PHPRunner General questions
E
Eddy Keuninckx author

This maybe something simple, but I can't see it. I have a dropdown field based upon a table. The dropdown is working fine: when I click it, all values of the table are shown.

When I want to make the dropdown dependent on the content of another field, I have an issue.
I added this to the WHERE-condition: Category = ':DetailCategory'

and when I fill a value by hand in the field "DetailCategory", all is working fine, the dropdownlist is filtered accordingly.
But when I set the value of the field by Javascript, the dropdownlist stays empty as if the field has no value in it. When I make the slightest change to the field (by adding a character and removing it again) all is working fine.
The code I use to set the value:

  • In a snippet (on the Add page):

    global $pageObject;

    if ($data = $pageObject->getMasterRecord())

    {

    $pageObject->setProxyValue(MasterCategory,$data["MasterCategory"]);

    }
    In Javascript OnLoad event:

    var ctrlDetailCategory = Runner.getControl(pageid, 'DetailCategory');

    ctrlDetailCategory.setValue(proxy['MasterCategory']);
    It is as if the soft is unaware of the value until I make a change manually. What am I missing?
    Thanks

woodey2002 2/12/2020

Hi Eddy,
Try adding this to your existing JS onload event at the end, leave the first JS event there also as is.

setInterval(function () {



ctrlDetailCategory.setValue(proxy['MasterCategory']);

}


https://asprunner.com/forums/topic/26742-conditionally-change-font-colour-on-addedit-page-control/
Cheers,

James

N
Nir Frumer 2/12/2020

hi

you might just add the field to the relation on the tables tab,

this will populate the value you want without any events code,
hope it helps

Nir.

E
Eddy Keuninckx author 2/12/2020

Thanks for the swift reply! I tried both of the proposed solutions but without result. It is as if the dropdown doesn't notice the change of the field "Category" and consider it as empty.
When I f.e. add a space to the field "Category" and then delete that space, it works fine.
When I save the record and reopen it, all is working fine. So it's only happening when adding a new record.
Cheers

Eddy

S
Steve Seymour 2/12/2020



Thanks for the swift reply! I tried both of the proposed solutions but without result. It is as if the dropdown doesn't notice the change of the field "Category" and consider it as empty.
When I f.e. add a space to the field "Category" and then delete that space, it works fine.
When I save the record and reopen it, all is working fine. So it's only happening when adding a new record.
Cheers

Eddy


random guess... does the field in the table default to NULL ? perhaps set it to NOT NULL

E
Eddy Keuninckx author 2/12/2020

Thanks halcyondaze, the field was set to NOT NULL. When I save the record, the field Category is saved with it's value and when I reopen the record, the dropdown is working as foreseen.

E
Eddy Keuninckx author 2/13/2020

I'm still working on this. Any idea if this could work or something similar?:

$("ctrlDetailCategory").trigger("change");
I'm not sure if this code is correct and if it can work.

S
Steve Seymour 2/13/2020



I'm still working on this. Any idea if this could work or something similar?:

$("ctrlDetailCategory").trigger("change");
I'm not sure if this code is correct and if it can work.


You'll have to try a few things til one works.... if it works. I have a similar type issue. An inline editbox change doesn't get triggered then the user uses the

small up/down arrows to increase/decrease the value. The only thing that triggers a change for a calculation is a keypress.

I've left at requiring a keypress for now while I contend with other things.

E
Eddy Keuninckx author 2/14/2020

He halcyondaze, do you have these issues in a popup window?

S
Steve Seymour 2/14/2020



He halcyondaze, do you have these issues in a popup window?


The arrows of a numeric edit don't trigger change in any mode. Add/Edit Page, Pop-Up or inLine...
So, I use keyup to call a function to do the calculation needed.

E
Eddy Keuninckx author 2/25/2020

I changed the field from "Dropdown box" into "list page with search" and that works. Dropdown would be better though.