Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Dynamically select multiple rows in web dynpro table

Hi All,

I am populating rows in a table by calling BAPI.

I set the selection property to 1..n for the context model node in view and custom controller.

I set the selectionmode property to multi for the table.

I have a "Select All" button in my view.

When i click this button, i want to select all the records in the table.

Then i want to loop thru the selected rows.

How can i do this?

Please give me some sample code or reference documents.


Former Member

Hi Tiruna,

To select all elements in the node you can use following code (created by Valery Silaev) where select parameters indicate to "select" or "unselect":

	public static void selectElements(final IWDNode node, final boolean select)
		final int leadSelection;
		if ( select )
			leadSelection = Math.min
				Math.max( 0, node.getLeadSelection() ), node.size() - 1 
			leadSelection = IWDNode.NO_SELECTION;
		for (int i = node.size() - 1; i >= 0; i--)
			node.setSelected( i, select );
		if ( 0 < node.size()) 
			node.setLeadSelection( leadSelection );

to iterate selected elements you can use:

for (int j = 0, n = wdContext.nodeRows().size(); j < n; ++j)
  if (wdContext.nodeRows().getLeadSelection() == j
    || wdContext.nodeRows().isMultiSelected(j)
    /* row at index j is selected */

Best regards, Maksim Rashchynski.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question