Having trouble with Field Editor appearing twice on the page

edited October 31, 2019 in Questions
On my page I have a Field Editor. That field editor sits in a wrapper. The Wrapper is within tab set. The field editor here points to a unique model (call it model U) that is only used for that field editor. That model is not loaded upon page load. The model is restricted to 1 record.

On the tab I have these whenever rendered actions:
Remove all rows from the other model on the page (model A) and from model U.
Query model B (that is used in a separate read only field editor)
Create a new row in model U.

Problem is if the user has queried and added a record form model A. Then when they go to the tab that creates the row in model U, the field editor that the user is going to use to select values for model U, appears twice. See attached. Very frustrating. No reason this should be happening in my view.image

Comments

  • edited October 29, 2019
    I don't spot any obvious issues with your setup, so I see how that could be frustrating. In my experience, in a Skuid page, there are many places where actions can be triggered, rows created, models queried, so it's good to take a deep breath and do a couple of sanity checks before throwing your keyboard. 
    So these "sanity" checks might be helpful:
    • Are there model actions on each of the models (A, B, and U)? You said "Problem is if the user has queried and added a record form model A" but all rows from model A should be removed by the "whenever tab renders" actions, so I'm not sure how that's causing a problem.
    • Model U is restricted to 1 record, but I think this restriction only applies to querying, and in this case, you're creating records, so it's possible to create more than 1 records in model U.
    • Drop in simple vanilla table components to help with debugging. If you put a table on the page for model U, does it show 2 records?
    • Nest in "show message and block UI" actions between each action on your "whenever tab renders" action list. See when/if these actions trigger. Use something like {{$Model.modelU.data.length}} to log out the numbers of records that model U has after each action.
    Hope that helps, and good luck!
  • edited October 30, 2019
    Are there model actions on each of the models (A, B, and U)? You said "Problem is if the user has queried and added a record form model A" but all rows from model A should be removed by the "whenever tab renders" actions, so I'm not sure how that's causing a problem.
    No. Just actions on 2 models. Action 1 to query data form model B and action 2 to crate a row in model U.

    Model U is restricted to 1 record, but I think this restriction only applies to querying, and in this case, you're creating records, so it's possible to create more than 1 records in model U.
    OK

    Drop in simple vanilla table components to help with debugging. If you put a table on the page for model U, does it show 2 records?
    Yes it does.

    Nest in "show message and block UI" actions between each action on your "whenever tab renders" action list. See when/if these actions trigger. Use something like {{$Model.modelU.data.length}} to log out the numbers of records that model U has after each action.
    I did this and is it showing a count of 2 in the model even though I saw create a new row only once.


  • edited October 30, 2019
    It seems like there 2 records being created, as confirmed by the table component and the block-ui logging. So the Field Editor is behaving correctly by showing up twice (# of rows in model = # of Field Editors shown on page). I wonder if there's a record being created in model U every time model B is queried. That could explain why there's always another record created. You can test this theory by removing the "Create New Row in model U" action from the whenever rendered actions in the tab and see how many records get created.  

    So your whenever rendered actions will just be:
    1. Remove all rows from the other model on the page (model A) and from model U.
    2. Query model B (that is used in a separate read only field editor) (---> Can this action be secretly creating a row in model U?)
    3. Create a new row in model U.
    Another trick I use sometimes is to add Model Actions to log out a message every time something happens in a model (new row created, field updated, etc). Here's a screenshare if that could be helpful to you 

  • edited October 30, 2019
    Another thing to check is whether there are actions for Whenever First Shown in the Tab. My setup below has the actions repeated for both "Whenever first shown" and "Whenever rendered", and on page preview, 2 records are created the first time the tab is opened (but not subsequent opens) 

    image 


    What happens on page preview: https://imgur.com/a/jvXe8w4 



  • edited October 30, 2019
     image
    I added a show message after the first query. That message counts rows in the model that are getting 2 records (OptiNIDDuoConfig). The initial count is 0. Then after the create new row it jumps to a count of 2. 

    I also added a count over on another area of the page that quires a model and again the initial count is 0. 

    For some reason the crate row action is creating 2 rows and it should not.

  • edited October 30, 2019
    I only have actions under Whenever Rendered.
  • edited October 30, 2019
    So I have found a work around.  I put a tab set within the other tab set and moved the actions to the inner tab set. Doing that cleared up the duplicate model rows issue.
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!