-2

I have a One to Many relation : One row in modelParent with Many row in modelChild

In a PanelList with the all modelParent rows, I want to hide the delete Icone on the row if the row has children link to this row.

What test should I do ?

Stef
  • 1
  • 1

1 Answers1

0

Right way

Don't hide the delete button, but show confirmation dialog that would tell user how many related records would be deleted with the selected record. You can find code samples in Project Tracker, People Skills and lots of other templates.

Easy to implement way (worse performance)

  1. Configure prefetch for your ParentModel's datasource to include records from ChildModel
  2. Bind delete button's visibe property to this:
@datasource.item.<NameOfYourRelationField>.length === 0

Harder to implement way (better performance)

You can create calculated model with special flag that you can use on UI to show/hide the delete button. This approach will also require lots of extra scripting for CRUD operations.

Pavel Shkleinik
  • 6,298
  • 2
  • 24
  • 36