cancel
Showing results for 
Search instead for 
Did you mean: 

sort a table in a Table UI Element

Former Member
0 Kudos

Dear Experts,

how can i give the user a chance to sort the data in a table ui element ?

In an ALV i can use a toolbar for this. Is there something like this in web dynpro ?

best regards

René

Edited by: René Hölterling on Jan 5, 2009 5:32 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

This will help you.

1. Go to Attributes Tab of your View , Give TABLE_CONTROL in the Attribute Column , Check the Check Box in the RefTo Column & give IF_WD_TABLE_METHOD_HNDL in the Associated Type.

2. Then create one Event for onSort Event of the Table by Clicking the Create Button . Then Give the Action Name as ON_TEST_SORT and press Enter.

UI Element-> table->properties->events->onSort.

3. Then go to the Methods Tab

4.Follow the below Code in the Corresponding Methods.

WDDOINIT:

method WDDOINIT .

data LO_ND_MARA type ref to IF_WD_CONTEXT_NODE.

data LO_EL_MARA type ref to IF_WD_CONTEXT_ELEMENT.

data LT_MARA type WD_THIS->ELEMENTS_MARA.

data LS_MARA type WD_THIS->ELEMENT_MARA.

  • navigate from <CONTEXT> to <MARA> via lead selection

LO_ND_MARA = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_MARA ).

SELECT MATNR MTART MATKL MEINS FROM MARA INTO CORRESPONDING FIELDS OF

TABLE LT_MARA UP TO 10 ROWS WHERE MATNR LIKE 'A%'.

  • Bind Table

LO_ND_MARA->BIND_TABLE( LT_MARA ).

endmethod.

WDDOMODIFYVIEW:

method WDDOMODIFYVIEW .

data wd_table type ref to cl_wd_table.check first_time = abap_true.

  • Name of the table UI element to be provided

wd_table ?= view->get_element( 'TABLE' ).

wd_this->table_control ?= wd_table->_method_handler.

*Name of the key attribute of the context node to which the table binding is done to be provided

wd_this->table_control->set_key_attribute_name( 'MATNR' ).

endmethod.

ONACTIONON_TEST_SORT:

method ONACTIONON_TEST_SORT .

wd_this->table_control->apply_sorting( ).

endmethod.

For more clear information go to SAPTECHNICAl->Tutorials->Webdynpro

Regards Madhu

Answers (2)

Answers (2)

pranav_nagpal2
Contributor
0 Kudos

Hi René,

create an event say Sort and bind it with onsort event of your table UI element.....

now you can write below code there

wd_this->table_control->apply_sorting( ).

regards

Pranav

arjun_thakur
Active Contributor
0 Kudos

Hi Rene,

Please refer to this link:

sort table column(http://saptechnical.com/Tutorials/WebDynproABAP/Sort/tablecolumn.htm)

I hope it helps.

Regards

Arjun

Edited by: Arjun on Jan 6, 2009 9:11 AM