cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving multiple rows selected from a table

i806184
Advisor
Advisor
0 Kudos

I want to retrieve selected multiple rows from a table and pass it to other views. Does anyone know how to implement this

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Vinoo,

You could use the "selectionmode" property of the Table UI element to select multiple rows from the table.

Set the value of the property to "multi".

Cheers,

Sam

Former Member
0 Kudos

And the node to which the table is bound should have selection set to 0..n

Regards

Pran

Former Member
0 Kudos

I missed some info...

Please make sure that you have set the "selection" property of the context node that is mapped to the table to "0..n" or "1..n".

In the controller program use the method "isMultiSelected" of the mapped Node to check whether the multiple lines are selected.

Cheers,

Sam

Former Member
0 Kudos

Let me please correct the terminology a little bit:

A UI element property (like Table.dataSource) can be BOUND TO a context node/attribute. (and not the other way round)

A context node/attribute can be MAPPED TO another context node/attribute.

Regards, Armin

i806184
Advisor
Advisor
0 Kudos

Thanks.

But once if isMultiSelected is true, how do i get the selected rows from the context. Any sample will be helpful

Former Member
0 Kudos

You could try a simple example:

Create a context node "Rows" with a string attribute "Text". Create some node elements in wdDoInit().

Create an action "ShowSelectedRowIndices" and implement the event handler as follows:


  //@@begin javadoc:onActionShowSelectedRowIndices(ServerEvent)
  /** Declared validating event handler. */
  //@@end
  public void onActionShowSelectedRowIndices(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionShowSelectedRowIndices(ServerEvent)
    StringBuffer msg = new StringBuffer("Multi-selected rows:");
    for (int i = 0; i < wdContext.nodeRows().size(); ++i)
    {
      if (wdContext.nodeRows().isMultiSelected(i))
      {
        msg.append(" ").append(i);
      }
    }
    wdComponentAPI.getMessageManager().reportSuccess(msg.toString());
    //@@end
  }

When executing the action (e.g. with a button) you will see the selected indices in the message area.

Regards, Armin