Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Using TableRow Index to set ReadOnly

Avatar

Former Community Member
I have a dynamic table that adds a new row whenever the button beside it is clicked. Pretty simple. When a new row is added there are two cells (text fields) that the user is supposed to enter. One of the cells contains an OK button. When the user clicks the OK button, I would like the entire corresponding row to be set to readOnly, so the values can no longer be edited.



I figure there is some way of accessing a single instance in a table using an index, but I cannot figure out the syntax. Everything I try always changes the first row in the table. Does anyone have any suggestions or help?



Thank you so much!
2 Replies

Avatar

Former Community Member
To get the index you would use this.parent.index. This will tell you which instance you are working with. Now that you know the instance you can address each of the objects by using the appropriate SOM Expression. To get the som expression I put an app.alert(this.somExpression); This will show you the structure you need to follow. The container for your object will have the instance number on it (i.e. form1[0].Page1[0].subform[*].fieldname[0] ...where * is the instance number.



Now when you go to set a value you cannot use [ ] in javascript so to create the expression you need this syntax:



xfa.resoleNode("form1.Page1.subform[" + this.parent.index + "]").fieldname.rawValue



Make sense?