• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Filtering a Combo Box based on another combo box

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Filtering a Combo Box based on another combo box

    Within the same form, I have two combo boxes (dropdowns). I would like to have the values available in the second combo box "filtered" based on what is selected in the first combo.
    In the past, I have done this using an app variable and vvIn_virtual in the data source. However, these specific data sources are also used in other widgets/apps.

    I thought you might have another way to do this (i.e. a newer NAB feature or different technique) but I wasn't able to find it.

    Any suggestions?

  • #2
    You can attach a "form helper" program. Upon the change of combo A, you can call the FilterCombo procedure to filter the results of combo B.

    Comment


    • #3
      So I did that but the combo B still contained all of the values from the initial load. I added the RefreshCombo procedure after the FilterCombo, which works on initial load and when I change the value of the combo A. However, if I cancel out of the "edit" and go back in, the combo B still contains the previously filtered data.

      In debug, it's not calling form helper when I exit the section and go back in (form is already rendered in the background maybe?).

      What's the best way to load/reload the combo box?

      Comment


      • #4
        Maybe try changing your form helper program to be called each time the form is shown...rather than only on creation.

        Comment


        • #5
          OK... so I've done that... I have it working basically the same using either RefreshCombo or an App Variable on the form field.

          Now, the dropdown is loading the correct values each time.. However, if I change the value in Combo A and the current value in Combo B is invalid (i.e. it goes empty), then cancel out of "edit mode" without saving the change. When I immediately go back in, the value in Combo B is empty instead of the actual (valid) value from the table.

          Kind of hard to explain, but this is weird.

          Upon viewing the form:
          image.png​

          I then select a different value from the "Accounting Code"
          image.png​

          The previous value is no longer allowed, but the combo updated to the allowed values.

          Now for the weird part... If I simply exit from Editing (which takes me back to the a different section of the application), then click the edit button again, When the form loads it stll shows the empty value even though the actual data contains the original (valid) value from the combo box.

          image.png​​

          Comment


          • #6
            If I use the NAB Dev Console to reload the widget, the value is correct.

            Comment


            • #7
              When you go back into edit are you reloading the data for that form?

              Comment


              • #8
                The Edit button calls an RPG program. On success, it sets these app variables. FYI - loadAR refreshes the widget data.

                image.png​

                The app variable "loadPaymentCombo" is linked to LoadData for the form field ACPMTT (payment type).

                image.png

                I also tried setting this this appvar to true on show section
                image.png​​

                Comment


                • #9
                  Additional note: If I immediately I go back into Edit for a third time, combo B form field is populated.

                  Comment

                  Working...
                  X