This topic is locked

Make dependent dropdown blank (Stay on "Please select")

5/23/2017 4:17:55 PM
PHPRunner General questions
H
headingwest author

Hi all,
I have a dependent dropdown which is NOT "required field". When the master dropdown is changed, the dependent is filled with the first value.
I want the dependent dropdown to remain on "Please select" - so nothing is selected, how do I do this?
So far I have added this to the OnLoad event but it doesn't work:



var ctrlAccount = Runner.getControl(pageid,'accounttypeid');

var ctrlChild = Runner.getControl(pageid,'parentid');
ctrlAccount.on('change', function(e) {

ctrlChild.setValue('');

ctrlChild.setValue(-1);

ctrlChild.clear();

ctrlChild.reset();

document.getElementById('value_parentid_1').selectedIndex = -1;

});


The HTML generated is:
<select size="1" id="value_parentid_1" name="value_parentid_1" class="form-control">

<option value="">Please select</option>

<option value="8">Stock on Hand</option>

</select>
Thanks.

jadachDevClub member 5/23/2017

In the Edit as dialog use " " as your default and auto update values for your 2nd dependent drop-down.

H
headingwest author 5/24/2017



In the Edit as dialog use " " as your default and auto update values for your 2nd dependent drop-down.


Hi Jerry, thanks but this didn't fix it. Any other ideas??

jadachDevClub member 5/24/2017

That is strange because it definitely works for me.

H
headingwest author 5/24/2017



That is strange because it definitely works for me.


What build are you using? I'm on 28765

H
headingwest author 5/24/2017

OK, I've narrowed down the behavior with dependent lookup default " ":
0 sub items -> Please select

1 sub item -> Selects the first item after please select

2 sub items -> Please select

3+ sub items -> Please select
So this behaviour only occurs with one sub item. Perhaps Sergey can make it consistent?

mbintex 5/24/2017

to me it sounds like a good "consistent" realization. If there is only one choice, why force the user to manually choose it?

H
headingwest author 5/24/2017



to me it sounds like a good "consistent" realization. If there is only one choice, why force the user to manually choose it?


Because in this case it forces an accidental choice on a field that should usually remain blank/empty. But there's no way to default to not choosing an option. The user would have to manually deselect it.

jadachDevClub member 5/24/2017



OK, I've narrowed down the behavior with dependent lookup default " ":
0 sub items -> Please select

1 sub item -> Selects the first item after please select

2 sub items -> Please select

3+ sub items -> Please select
So this behaviour only occurs with one sub item. Perhaps Sergey can make it consistent?


This is interesting. I see what you mean. When only one choice, it displays that choice, anything over one, it works.

H
headingwest author 6/5/2017

If anyone else is struggling with this, here is the suggestion from support:
Find this snippet in the <PHPRunner directory>\source\include\common\runnerJS\DropDown.js:

----------------------------------------------------------

if ( ctrl.optionsDOM.length == 2 && !ctrl.multiSelectionAllowed || ctrl.optionsDOM.length == 1 && ctrl.multiSelectionAllowed ) {

ctrl.setValue( [ ctrl.optionsDOM[ ctrl.optionsDOM.length - 1 ].value ], false );

} else {

ctrl.setValue( selectedValues, false );

}

------------------------------------------------

and replace it with

------------------------------------------------

ctrl.setValue( selectedValues, false );

------------------------------------------------

That will make the dependent dropdowns work as you want them to.

lefty 6/6/2017



If anyone else is struggling with this, here is the suggestion from support:
Find this snippet in the <PHPRunner directory>\source\include\common\runnerJS\DropDown.js:

----------------------------------------------------------

if ( ctrl.optionsDOM.length == 2 && !ctrl.multiSelectionAllowed || ctrl.optionsDOM.length == 1 && ctrl.multiSelectionAllowed ) {

ctrl.setValue( [ ctrl.optionsDOM[ ctrl.optionsDOM.length - 1 ].value ], false );

} else {

ctrl.setValue( selectedValues, false );

}

------------------------------------------------

and replace it with

------------------------------------------------

ctrl.setValue( selectedValues, false );

------------------------------------------------

That will make the dependent dropdowns work as you want them to.


I'd like to chime in on this . Do you have unique values checked in your dropdown? If you have the possibility of having more than one dependant dropdown than yes it will pick the first one in database dependant on link field . I have noticed that in all versions of phprunner. For string values Uncheck Unique values and add a concat in display choices to differentiate the choices And change to edit box with ajax popup or still use drop down which should work. " Please Select always comes up if there are more than one possible match. " So take out default values and all javascript you changed , if you don't want to change the source code. I think this is a much easier solution.

H
headingwest author 6/6/2017



add a concat in the dropdown ( display) to differentiate the choices. When I use this " Please Select always comes up if there are more than one possible match. "


Hi John,
Just checking we're all talking about the unique behaviour when there's only one dependent to the parent. See it at my demo account here:

http://demo.asprunner.net/jim_storey_divacoffee_com_au/test/test_add.php
Also - I tried adding concat into Display Field as follows:

concat(description, ' ')
But still had the same behaviour.

lefty 6/6/2017



Hi John,
Just checking we're all talking about the unique behaviour when there's only one dependent to the parent. See it at my demo account here:

http://demo.asprunne...st/test_add.php
Also - I tried adding concat into Display Field as follows:

concat(description, ' ')
But still had the same behaviour.


LOL , I get ya now. I never had to that . I will have to file this one. Thanks .