Skip to Content
avatar image
Former Member

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.


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jul 26, 2006 at 01:10 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 26, 2006 at 04:11 AM


    If your data is coming from a BAPI another alternate solution would be to add a checkbox to your bapi table parameter. On clicking Select All on the view, pass this as a flag to your BAPI (field type wdboolean) and loop at the table in your bapi to set the checkbox field to X.

    Bind this checkbox field to the corresponding checkbox column of the table in your view. This will maintain consistency in all the logic residing in BAPIs

    Let me know if this helps.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi all,

      I'd used the code listed above but i can't obtain a total visual selecting of all rows of the table.

      I want to select / unselect by a simple button all the rows of a table and I would to see on the view all the rows selected into the orange frame.

      Can everyone tell how do I proceed ??

      Thanks a lot.

      Message was edited by: Gianluca Barile