on 05-12-2009 7:01 AM
Hi experts,
How to copy only some of the elements from one node to another node based on condition ?
Thanks,
kavya.
Hello KAVYA
---> if you want to copy all the elements of one node to another node, then the method
WdCopyService() can be used as shown below:-
WDCopyService.copyElements(wdContext.nodeSourceNode(),wdContext.nodeTargetNode() );
It will copy all the elements of source node to the target node.
--> However if you want to copy only some of the elements based on some situation then you should use a for loop to get each element and copy(add) that element to new node based on the condition as shown below:
wdContext.nodeTargetNode().invalidate();
int size_SourceNode = wdContext.nodeSourceNode().size();
for(int i = 0 ; i < size_SourceNode ; i++ )
{IPrivateTestMenuAppView.ISourceNodeElement src_el = wdContext.nodeSourceNode().getSourceNodeElementAt(i);
Condition = src_el.getA().equalsIgnoreCase( "s"); //condition to check the element which needs to be copied.
if(Condition)
{
IPrivateTestMenuAppView.ITargetNodeElement Tgt_el = wdContext.nodeTargetNode().createTargetNodeElement();
Tgt_el.setA( src_el.getA());
Tgt_el.setB( src_el.getB());
wdContext.nodeTargetNode().addElement(Tgt_el);
}
}
In this way the elements can be added to the other node based on the condition.
Hope it is clear.
Please let me know if you still have any problem in this.
Sarbjeet Singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Kavya,
Try to use teh following code:
Iprivateview sourcee table ;
Iprivateview targettable ;
for(int i =0;i<sourcesize;i++)
{
sourcetable = wdcontext.nodesourcetable.gettableelementat(i);
targettable = wdcontext.nodetarget.currenttable.createlement();
targettable.set();
targettable.set();
.
.
.
wdcontext.nodetargettablename.addelement(targettable);
}
I hope this helps. If you need some thing else, please revert back, I'll be happy to help you.
Cheers!!!
Umang
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
for copying one node to another u can use this also
int size=wdContext.nodeAbc().size();
for(int i=0;i<size;i++){
IPrivateTimerView.IAbcElement eleABC= wdContext.nodeAbc().getAbcElementAt(i);
boolean check=eleABC.getCheck();
if(check)
{
IPrivateTimerView.IAbc_1Element eleABCCopy= wdContext.nodeAbcCopy().createAbcCopyElement();
eleABCCopy.setAmount(eleABC.getAmount());
eleABCCopy.setName(eleABC.getName());
wdContext.nodeAbcCopy().addElement(eleABCCopy);
}
}
here u can copy abc node data to abcCopy node when check(attribute) value is true.
Regards
Trilochan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.