0 votes
3.0k views
in Activities & Tasks by (120 points)
I have a collapsible panel which display set of information pulled from database on display text fields. Based on the data i want to access the corresponding collapsible panels text field and update the label of it.

I used index to identify which collapsible panel i need to select but for the text feild i cannot access it using this

$textboxname[i].setLabel()

But i can do this

$textboxname[1]. SetLabel()

Please tell me a way to get the parameterized one working

1 Answer

0 votes
by (30.6k points)

A Collapsible Panel bound to a list is repeated once per element; every repetition has the same control names, so page.ui.get("Text1") only returns the first one. Address the instance you need through the list index or through the repeating parent.

1. Path addressing with the index (UI Toolkit / Spark syntax): a control inside a repeated container is reachable as Parent[i]/Child:

// third panel (index 2) of the repeated collapsible panel "Panel", its text control "Amount"
var amount = page.ui.get("Panel[2]/Amount");
amount.setData("1250.00");
amount.setValid(false, "Amount exceeds the limit");

2. Loop over all repetitions when the decision depends on the data of each row:

var rows = page.ui.get("Panel");            // the repeating parent
var n = rows.getRecordCount ? rows.getRecordCount() : ${Panel}.getData().length;
for (var i = 0; i < n; i++) {
  var txt = page.ui.get("Panel[" + i + "]/Amount");
  var item = ${Panel}.getData()[i];             // the bound list element of this repetition
  if (item.status === "OVERDUE") txt.setColorStyle("E");   // red
}

3. From inside the panel itself (an event handler of a control in the same repetition) use relative addressing: me.ui.get("../Amount") resolves within the current repetition, and me.context.binding.get("value") gives the element of the list the repetition is bound to - no index needed.

Give the controls in the panel unique control ids (the Control Id field of the properties), the label is not the id.

References

Related questions

0 votes
1 answer 1.7k views
0 votes
1 answer 2.5k views
0 votes
1 answer 2.0k views
0 votes
2 answers 4.0k views
0 votes
2 answers 2.9k views
0 votes
1 answer 2.2k views

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...