319
Views
3
Comments
Solved
Adding and removing values from dropdown tags
Question
Application Type
Reactive

Hi guys,

I really do need some help and advice here. Let me give a brief walk thru on the background,

This application is to submit either nomination for individual or team awards. So when the user clicks on whatever option there is, the relevant data are being loaded.

  1.  The Individual dropdown and Team leader dropdown, are using the same data - GetStaffs. Both are also using the DropdownSearch widget
  2. The team members dropdown, is using GetTeamMembers. It is basically the same STAFF entity, just that the leader name has been filter out. This is using the DropdownTags widget
  3. Because of how the entities are being structure, local variables 'TempManager', 'OfficerId' are being created to obtain and store the values.

My main question is, how get i pass and store the leader and members value into the local variable 'TeamList'. Because this TeamList, will eventually be the parameter i pass into the Create/Update action, there, i can do a ForEach loop to add the nominees. 

However now, when i'm selecting the team members and then tried removing them, i couldn't get around the logic of how to do it.

When user remove a selection from the members, i want to remove it from my TeamList too. I have search the forums here, and typically what the suggested solution is, on the OnChange event, do a ListClear, and follow up a ListAppendAll for the SelectedOptionList to TeamList.

However, doing this, will remove my team leader value too. 

Would like to seek advice, on what would be a efficient method of handling this.


Thanks!


MockUp_CS.oml
MockUp_UI.oml
2024-03-14 12-00-57
Carlos Costa
Solution

Yes for the StartingSelection you need to create a new variable and pre-populate that variable with the results that you want. You only have the Value and the Label but technically you just need the value (which is your id). 
Imagine that you want Master to be automatically selected, then you need to create a new variable and append the Master id to the Value element


And that will make Master pre-selected whenever you enter the page


(I'm not considering the rest of the logic to show the second dropdown, but that's just replicating the OnChange of the first dropdown)

Then you assign your new variable to the block DropdownSearch

2024-03-14 12-00-57
Carlos Costa

Hello Jun,
If I got it correctly, what you are trying to achieve on Team Members is Employees that have the manager = to the selected on the Team Leader dropdown.

For the database I used the following data:I've made a change on the GetTeamMembers aggregate, because I thought you didn't want to show the Team Leader in the Team Members list (but correct me if I'm wrong)The first filter forces the employee that is the team leader to be hidden and the second filter forces to select users that are under the manager selected (team leader)

Then I've added a new expression to the screen to show the team members that were selected.

You were right saying that you need to clear the team list and then append everything back again.

I'll add both the OMLs, let me know if this is what you were looking for.

MockUp_CS.oml
MockUp_UI.oml
2022-05-01 03-47-53
Jun Mun Chan

Hi Carlos!

Thank you for your reply. Yes, I didn't provide enough concept for the logic. I apologise for it.

For the team awards, anybody can be a team leader. In the entity, the reason why I have included their managerId, is really because it will be easier for me to query the manager email and send them a notification after the user submit the nominations. 

The only difference between the GetStaffs (to select the leader, and all staff will be shown) and GetTeamMembers (All staff, excluding the leader, will be shown)

I guess at least for the team leader, i think i might have to create another local variable to store the values, and then append it to the TeamList variable during submission.

Another feature I am looking at, is the StartingSelection option. As the user can save a draft and when the user returns to the nomination page, if user had selected some team members prior, i want the DropDownTags to be populate with the values too.

In my existing actual app at work, i had managed to do it but it is using DropdownSearch. The logic is definitely different from this MockUp, and I do have quite a few variables to store the different values, and it was easier for me to display the values using StartingSelection option.

Think maybe what I am really confuse about, is that, I know the TeamList variable is the parameter I will be passing into the Create/Update server action, so i'm trying to populate its values in the OnChange handler. But the DropdownTags' SelectedOptionList only have Value and Label. 

So maybe i am really struggling with linking TeamList and SelectedOptionList together.

I do hope i didn't make this more confusing.


Thank you. 

2024-03-14 12-00-57
Carlos Costa
Solution

Yes for the StartingSelection you need to create a new variable and pre-populate that variable with the results that you want. You only have the Value and the Label but technically you just need the value (which is your id). 
Imagine that you want Master to be automatically selected, then you need to create a new variable and append the Master id to the Value element


And that will make Master pre-selected whenever you enter the page


(I'm not considering the rest of the logic to show the second dropdown, but that's just replicating the OnChange of the first dropdown)

Then you assign your new variable to the block DropdownSearch

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.