How to filter the drop-down list controls if there is no relationship

  • 15 February 2022
  • 0 replies
  • 191 views

Userlevel 5
Badge +20
 

How to filter the drop-down list control if there is no relationship

KBS100116

PRODUCT
K2 smartforms 4.7
BASED ON
K2 smartforms 4.7
This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.
LEGACY/ARCHIVED CONTENT
This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.

Objective

How to populate the drop-down control and filter it based on a different drop-down control selection, when they do not have any relationship with one another.

Before You Begin

First you need to identify which question should display which operator, as we already know that a particular question has a particular operator value.

So let's use this example: If the question is "Is this Valid?" then the operator should populate the operator drop-down list with "Equal to" and "Not Equal To".

To allow the operator to return the correct value it would first need to filter the value upon a re-population of the operators drop-down list, after a condition check against the questions' drop-down list has been identified as true.

For example: If the question is "Is this Valid?", then on the questions' drop-down list we would need to check if the drop-down list is equal to "Is this Valid?" This will then validate to either true or false. If it validates to true then the operators drop-down list should be re-populated and a filter should be added to the re-population rule specifying which operators should be made available in the operator drop-down list when the questions drop-down list is equal to the question "Is this Valid?"

If the question changes, this entire condition should be re-executed.

How-to Steps

  1. Get setup first:
  • Create a SmartObject and call it 'Questions' with an ID=Autonumber property and a Questions=Text property.
  • Create another SmartObject and call it 'Operators' with an ID=Autonumber and an Operator=Text property.
  • Generate an Editable list view for each of the above SmartObjects.
  • Run the Questions Editable List view and add some questions.

    pop10.png
  • Run the Operators Editable list view and add the following operators [ Greater Than, Equals To, Not Equal To, Less Than ]pop9.png
  • Create an Item View and add two drop-down lists to the canvas. Configure the first drop-down lists Data Source to the Questions SmartObject and the second drop-down lists Data Source can be configured to the Operators SmartObject.popresult1.png
  1. Now to add the rules, that will do the check:
  • Since the drop-downs already have data sources connected to them at this point, that will mean that the views "Initialize" rule would have auto generated population rules for each drop-down list. You can disable or remove the Populate rule for the Operator SmartObject as we are going to call it somewhere else. This step is optional depending on if you need the drop-down list to be populated on initialize or not.
     
  • Add a new rule on the questions drop-down list for when it gets changed.
     Pop1.png
  • Add a condition check to see which question is selected

    pop2.png
  • Add the Operators populate list control with data rule and add your filters depending on what should be returned when the specified question is selected.
    pop6.png
    pop7.png


This solutions' tested result can be seen below.

popresult2.png


Additional Scenario | For situations where the SmartObject has quite a lot of items you can use the following steps instead:

    • Add a data label, set its visibility to hidden.
    • When the questions drop-down list is changed instead of having a condition you can transfer data which will transfer the selected drop-down lists items ID/Question to the data label.
    • On the data label change add a advanced condition rule the checks if the data label value is equal to the drop-down lists ID/Question (Depending on whether you previously used ID/Question). Then populate the Operators drop-down list.
    • On the Operators drop-down list populate rule, add a filter that checks if the ID/Question (which ever was used) is equal to the data label and that should do the trick.

0 replies

Be the first to reply!

Reply