on 12-23-2005 3:25 PM
Hi,
My code produces unexpected behavior. When I execute the following code, the elements are added but other (existing) elements are duplicated.
When I replace "addElement(i, el)" with addElement(el), it works fine, except the tablerow is inserted at the end of the table, which is not the right location.
i=0;
IPrivateResultView.IEp_OpportunitiesNode node = wdContext.nodeEp_Opportunities();
while ( i < node.size() ) {
total1 += <some value>;
if (<start of new section>) {
IPrivateResultView.IEp_OpportunitiesElement el = (IPrivateResultView.IEp_OpportunitiesElement)
node.createElement(new Zopportunities());
el.setAttributeValue("Exp_Revenue", new BigDecimal(total1));
/* totals row is added here: */
node.addElement(i, el);
total1 = 0;
}
i++;
}
Thanks in advance,
Roelof
Message was edited by: Armin Reichert
If I understand your code correctly, you want to insert "total" rows at certain indices.
The problem with your code is that you are adding elements to the node that you are iterating.
You could iterate the node and build a second list "elementsWithTotals" where you either add the current element or a new "total" element.
After the loop, rebind the node to the new list.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
see if this helps...
i=0;
IPrivateResultView.IEp_OpportunitiesNode node = wdContext.nodeEp_Opportunities();
while (i<node.size()) {
total1 += <some value>;
if (<start of new section>) {
IPrivateResultView.IEp_OpportunitiesElement el = (IPrivateResultView.IEp_OpportunitiesElement) node.createElement(new Zopportunities());
el.setAttributeValue("Exp_Revenue", new BigDecimal(total1));
// totals row is added here:
<b>node.addElement(i, el);</b>
<b>instead use</b>
<b>i++;</b>
<b>node.addElement(i, el);</b>
total1 = 0;
}
i++;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.