on 09-04-2009 6:03 PM
Hi Experts,
I want to loop over a node and remove all elements in this node if they don't match a certain pattern (which needs to be checked by getting the details o these elements).
So looping over the node and checking whether the pattern matches works pretty fine (I've checked by using a counter variable which counts the number of matches and compares to the total size of the node). But removing the elements does not work.
I always get the complete table as the result but not without all those elements I that they'd be removed already. I also check the success status (boolean) of the remove function and it delivers always "true" so it seems to work.
This is the relevant coding:
for(int c = 0 ; c < wdContext.nodeMatnrlist().size() ; c++){
wdContext.nodeMatnrlist().moveTo(c);
GetMaterialDetails(wdContext.currentMatnrlistElement().getMaterial());
if(!wdContext.currentMaterialDetailsElement().modelObject()
.getOutput().getMaterial_General_Data().getCreated_By().equals("BAIV-SS09-21")){
success = wdContext.nodeMatnrlist().removeElement(wdContext.nodeMatnrlist().getCurrentElement());
counter++;
}
}
any Ideas on this?
Many thanks in advance!
Cheers
Tobias
Edited by: Tobias Fickinger on Sep 4, 2009 7:04 PM
Loop backwards to avoid index troubles:
IWDNode node = ...;
for (int i = node.size() - 1; i >= 0; --i)
{
IWDNodeElement e = node.getElementAt(i);
if ( condition(e) )
node.removeElement(e);
}
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If u want to remove the row at position "i" in a table, then use this piece of code:
wdcontext.nodeVn_Table.removeElement( wdcontext.nodeVn_Table.getVn_TableElemenyAt(i)));
Regards,
Himanshu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tobias.
Try this instead:
wdContext.nodeMatnrlist().invalidate();
Regards.
Julio Herrera
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
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.