0 votes
1.2k views
by (190 points)
I have list which contains all liabilities of person.

On loading this list object I want to show only active liabilities, not to loose other ones.

1 Answer

0 votes
by (30.6k points)

Bind the table to a second list that holds only the active items, and keep the full list untouched in its own variable. Filter once when the coach loads and re-filter when the data changes:

// CSHS: variables tw.local.liabilities (all), tw.local.activeLiabilities (shown)
// client-side script task before the coach, or the coach's "load" event:
tw.local.activeLiabilities = tw.local.liabilities.filter(function (l) { return l.status === "ACTIVE"; });
// (in a coach view / control event use the control API)
${ActiveTable}.setData( ${AllHidden}.getData().filter(function (l) { return l.status === "ACTIVE"; }) );

When the user edits a row of the active list the edit lands on the same objects (the filter copies references, not values, in the browser), so the full list keeps the change - but only until a server round trip re-serialises the data. If the coach submits, merge back explicitly:

// before submit: write the edited active items back into the full list by id
var full = tw.local.liabilities, act = tw.local.activeLiabilities;
act.forEach(function (a) { for (var i = 0; i < full.length; i++) if (full[i].id === a.id) full[i] = a; });

Alternative without a second variable: the UI Toolkit table supports a filter (search box) and, on newer toolkits, a Row filter formula (${Table}.setFilter(...) / "Filter" option) that hides rows without removing them from the bound list. That keeps one variable and no merge, at the price of the full list being sent to the browser.

References

Related questions

0 votes
1 answer 1.6k views
0 votes
1 answer 2.3k views
+1 vote
1 answer 4.9k views
0 votes
1 answer 4.1k views
+1 vote
1 answer 1.2k views
0 votes
1 answer 1.0k 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
...