Remove rows from model not working as I expected!

MonicaMonica ✭✭
edited April 2, 2020 in Questions

Hi have created 2 row actions:

1. Select Record – adopts the row into a to a model SelectedAccounts

2. Deselect Record – removes rows from model SelectedAccounts

The problem I am having is that the Select Record is working, but he Deselect Record does not work. So, if I select record 1, 2 and 3. They are added to the SelectedAccounts model. But if I deselect 1, 2 and 3 they are not removed from the model.  But, if I deselect 4, then then 1, 2, 3 and 4 are removed from the model. What am I doing wrong???

Comments

  • edited March 26, 2020
    Are the two actions both on the same table? Like they're both on AccountsList, and then they're supposed to adopt/remove from SelectedAccounts?
  • MonicaMonica ✭✭
    edited March 26, 2020
    Yes.
  • edited March 27, 2020
    The issue sounds like the Deselect Option doesn't have the right context, since the action is on a different model than the one you're trying to remove from. 

    It's a little roundabout, but to accomplish this you could do something like this with the remove row action...
    1. Updates a Feld on a UI-Only Model and stores the AccountId
    2. Toggles a checkbox in SelectedAccounts Model (ui-checkbox)

    Then that SelectedAccounts model is set up with...
    3. SelectedAccounts Model has a Model Action when Row Updated w/ field ui-checkbox
    4. That Model Action starts with a branch thats {{$Model.UI-Only-Model.data.0.AccountId}} == {{Id}} (If the Id matches the record you said you want to remove)
    5. If true, remove row in context
    6. If false, do nothing
  • MonicaMonica ✭✭
    edited March 28, 2020
    Matt,

    Thanks for your help. I think I did everything you said, but if I have a list of 10 accounts and select records 5 & 6. Then deselect 6, the checkbox on the appropriate SelectedAccount record is checked, but the Ui-Only AccountID is that of record 1. It is not the ID of record 6. So record 6 is not removed from the SelectedAccount model.


  • MonicaMonica ✭✭
    edited March 28, 2020
    Matt,

    I changed the Model Action Branch formula on the SelectedAccounts model to {{Selected}}==True.  And it worked. Thanks so much!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!