on 10-02-2009 12:28 AM
Hi All,
Lets say i have a node Test with cardinality 1..n with some attributes name and city,Now lets say the test node size is 10;so this has nodeelement0,nodeelement1,nodeelement2...nodeelement9. so this order will be displayed in view if we attach this to table, but i want to reorder these nodelements of Test node like nodeelement2,nodeelement7,nodeelement1,nodeelement4...nodeelement0 . so my first row of table will be in this order.
i tried swapElements and moveElement of IWDNode but could not find the solution.
for(int i=0;i<n1;i++)
{
ITestElement elementAtI=wdContext.nodeTest().getTestElementAt(i);
if(elementAtI.getName().equalsIgnoreCase("k0"))
{
wdContext.nodeTest().moveElement(i,9);
}
else if(elementAtI.getName().equalsIgnoreCase("k2"))
{
wdContext.nodeTest().moveElement(i,0);
//more elseif conditions
}
}
but at the end the reordering of the elements didnot worked in the order i expected.Please provide your suggestions.
Thanks,
pkv.
Edited by: pkv on Oct 2, 2009 1:28 AM
hi,
One easy solution for your problem would be to create another node of the same context structure as your table node.
Add elements to the temporary node in the order you want. Finally invalidate table node and use copyElements() method to copy elements from temporary node to table node.
Otherwise swapelements()and moveelement() would also work if you use them in a correct way.
Hope this helps!
Monalisa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi pkv,
even if its a referenced node, you dan use WdContext.nodeTest.invalidate() to clear the node and then loop over the Temp node and add these elements to your nodeTest.
generally, the logic shlound be in the component controller, not in the view. so the reordering of the contextelements shlould be coded there.
please award points for helpful answers.
best regards,
christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Armin,
it's sad to see, that SAP employees themseves seem to say to people "don't give somebody points". SAP has this beneficial thing running. Not me. SAP has no more money so you encourage people, not to give any points? Or is there another really good reason, to get this thread off topic? If you get a "thank you for your help!", why don't remember the people also to give some points, when they do not? YOU wan't an active community. So you should get the memner motivated and not demotivate them.
I'm sorry for this off topic message. But I don't think that these "Don't say this, don't say that" messages from SAP people help to solve problems.
I know that you know a lot. so why do you post such a comment? Wouldn't it have been better, when you had just written the solution to pkv's problem?
I'd suggest, deleting Armins message and this message, so this thread can remain on it's toppic.
Best regards,
Christian
Christian,
Neither did I tell people to not give points for helpful answers nor did I claim having discussed with you about this "rew@rd points" nonsense. So please just stop turning words in my mouth. And your question if I don't want to help solving the question of this thread is just an infamy.
Armin
Hi Armin,
You wrote, "I don't want to discuss that with you again". The words "with you again" tells me, that we should have discussed this already. In this case, I might have got you wrong an you didn't mean it as I understood it.
But either you see it as "infamy" or not, I don't think, that this nonsense about who is right and hwo wants to be right will help pkv. And surely it won't increase the threadquality.
best regards,
Christian
your sorting doesnt work for one reason: moveElement() does nocht exchange teh elements. if you have 5 elements
12345
and you do moveElement(0,4) you get
23451 instead of 52341.
moveElement() moves the element to the desired position and moves all other elements one up or down, depenedent on the relative potition of the moved element before moving.
what you could do is creating another context node, with the same structure to add the elements.
then you have to change your program a little.
first, you have to sort your if statements.
second, you will add the element to the other context. lets say nodeTemp.
for(int i=0;i<n1;i++)
{
ITestElement elementAtI=wdContext.nodeTest().getTestElementAt(i);
if(elementAtI.getName().equalsIgnoreCase("k2"))
{
wdContext.nodeTemp.addElement(elementAtI);
}
else if(elementAtI.getName().equalsIgnoreCase("k0"))
{
wdContext.nodeTemp.addElement(elementAtI);
//more elseif conditions
}
}
in the nodeTemp, you will have your reordered elements. either you take these elements back to your original context, or you use this temporary context to show the data in your table.
best regards,
Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christian,
Thanks for your help,i dont need ascending or descending order, i want it in a predefined hardcoded order, and this node Test is a reference from model node, so i copying in to another temp value node in my required order and recopying this to model node may not work.so i am trying to changes the order of the Test node in the component controller and there by using same in the view.
Thanks,
pkv
hi pkv,
do you need a hardcoded ordering or would a ascending/descending sorting of the nodes do for you? this could be done much easier than coding an if for every node. for sorting, take a look at this: http://wiki.sdn.sap.com/wiki/display/Snippets/SortingContextNode
could you explain, in which way your rodering isn't working? do you get ste same result as before ordering? od an almost correct ordering?
best regards,
Christian
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.