Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

use variable value

Avatar

Level 5

Hi All.

I button to add row of table Table1._Row1.addInstance(true);

and button to delete row    Table1._Row1.removeInstance(this.parent.index);

I would like create a condition that user can delete rows only if table has more then one row. And Detete button display only if table has more then one row. How it to do?

Thanks.

2 Replies

Avatar

Level 10

What would be more user friendly is if you have a delete button on the first row even if there's only one, and instead of having the row deleted you change reset the row

if (this.parent.instanceManager.count > 1){

     //remove instance

} else{

     xfa.host.resetData(this.resovleNode("Row1").somExpression);

}

if you hide the button delete you have to check if the count is higher than one you show the button, if the row is == 1 you hide the button

button.presence = "visible";

button.presence = "hidden";

Avatar

Level 10

Hi,

you can use an if expression for both of your questions.

Remove Row only if there are more than one.

if (Table1.Row1.count > 1) {

     Table1._Row1.removeInstance(this.parent.index);

}

Hide button if there is only one row.

this.presence = Table1.Row1.count > 1 ? "visible" : "invisible";

Hope this helps.