cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple lead selection in a table

Former Member
0 Kudos

Hi.

For a table ,to get the lead selection for a selected row, I used to get it by

 int ls=wdContext.nodeABC().getLeadselection() 

so based on the ls value i get the current element and perfom my logic.

I have set the property for the ui element table "Selection Mode"=Multi.

How do I do the same in case more than 1 row is selected (multi row selection)?

How to get the reference for the element in this case?

Regards

Bala

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Read the Javadoc for IWDNode:


  /**
   * Returns whether the element at the given index is selected. Does not look
   * at the lead selection.
   * 
   * @param index the index of the element
   * @return true if the element is selected.
   */
  boolean isMultiSelected(int index);

In release 7.20 there exists a new API.

Armin

Former Member
0 Kudos

Hi Armin.

Thanks for your reply.

As per your reply, isMultiselected method will give you if the element at the given index is selected or not.

But my requirement is I need to delete the rows from the table based on the rows selected. If a single row is selected, then I can do it using lead selection and get the reference for the element and remove the element using

 removeElement(IWDNodeElement element) 

How can I achieve(deleting the rows from the table) if multiple rows are selected?

Thanks

Bala

Former Member
0 Kudos

Hi,


    IWDNode nodeTable = wdContext.nodeTable();
    for (int i = 0; i < nodeTable.size(); i++) {
    	if (nodeTable.isMultiSelected(i)) {
    		IWDNodeElement tableElement = nodeTable.getElementAt(i);
		nodeTable.removeElement(tableElement);
    	}
    }

Hope it helps,

Daniel

Former Member
0 Kudos

Hi Daniel.

It works. Can you tell me if the same kind od approach is available/applicable for a recursive node.

Thanks

Bala

Edited by: Balachandar P on Feb 4, 2010 6:22 AM

Former Member
0 Kudos

You must loop backwards from node.size() -1 to 0. Otherwise the removal of an element changes the index of the following elements in the loop.

Armin

Former Member
0 Kudos

True. Or use (i--) when removing. It should work as well.

Former Member
0 Kudos

That would not help. You have to iterate through the element list such that deleted indices are not visited again.

Armin

Former Member
0 Kudos

Hi Armin,

Im curious, and you would be able to answer.. can you tell me a good reason why removeElement does not accept and int? - The underlying implementation does exactly that (and it checks for element.node() but this is completely irrelevant) - I know that you were not one of the designers of WDP but I guess you might know a couple.. 😛

Cheers,

Daniel

Former Member
0 Kudos

"I know that you were not one of the designers of WDP"

How can you know?

Armin

Former Member
0 Kudos

I was being sarcastic..

Daniel

Former Member
0 Kudos

Nevertheless. I will ask the designer of the context API why it is that way.

Armin

Former Member

Answers (2)

Answers (2)

p330068
Active Contributor
0 Kudos

Yes, Armin is correct.

Take first lead selection and put on the other(XYZ) node element, then check for another lead selection and put on the other(XYZ) node element and so no.

Arun

Former Member
0 Kudos

"Take first lead selection and put on the other(XYZ) node element, then check for another lead selection and put on the other(XYZ) node element and so no."

This sentence makes no sense to me. There is only one lead selection in a node.

Armin

p330068
Active Contributor
0 Kudos

Hi Armin,

For finding multiple lead selection(or multi row selected), we need to iterate through node to find 1st lead selection and again n again we need to iterate through node for finding next selected row - correct

For selected rows, we need to store somewhere for further processing.

Hope that is fine now

Thanks

Arun Jaiswal

Former Member
0 Kudos

There don't exist multiple lead selections.

Armin

Former Member
0 Kudos

It works for a normal node, but need to know how recursive node works