on 06-19-2008 10:51 AM
Dear All,
Can you please help me on as how and where to program the onSort event?
In my application I am fetching bukrs, butxt, ort01 and spras.
I want to have an ascending sort on any of these fields.
Please help.
Regards,
Prosenjit.
Hello,
Please see this guide: [/people/mohammed.anzys/blog/2007/07/22/webdynpro-abap-quick-tips-10table-column-sorting-in-four-steps].
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In the ATTRIBUTES tab of the view include
TABLE_CONTROL IF_WD_TABLE_METHOD_HNDL
In onSort method use following code,
wd_this->table_control->apply_sorting( ).
In MODIFYVIEW method use the following,
method WDDOMODIFYVIEW .
data wd_table type ref to cl_wd_table.
check first_time = abap_true.
wd_table ?= view->get_element( 'TABLEELEMENT' ).
wd_this->table_control ?= wd_table->_method_handler.
wd_this->table_control->set_key_attribute_name( 'REPORTNUMBER' ).
endmethod.
where,
TABLEELEMENT -> id of the table node UI element
REPORTNUMBER -> column name of the table
Regards,
Dinesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi prosenjit.....
for all table ui elements you have teh event called on sort. when you give an event name, it automatically creates a method where you should read the node which is bound to the table, sort it using sort syntax and then bind it back again to the table.
---regards,
alex b justin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Following sample code can help you...
Declare a field with name col and type string as an importing parameter to your onsort method of the table. The field col will have the name of the column which the user has requested for a sort and direction will have the sort direction. (00-Ascending and 01 descending). Based on these two inputs you can perform the sorting of the internal table and bind to the context
method ONACTIONONSORT .
data: lv_direction TYPE string.
CALL METHOD WDEVENT->GET_STRING
EXPORTING
NAME = `DIRECTION`
RECEIVING
VALUE = lv_direction.
wd_Comp_Controller->Onsort(
COLUMN = col " String
DIRECTION = lv_direction " String
).
endmethod.
OnSort method of component controller can be as follows:
Node_Intr_History = wd_Context->get_Child_Node( Name = IF_COMPONENTCONTROLLER=>wdctx_Intr_History ).
Node_Intr_History->get_Static_Attributes_Table(
importing
table = Int_Intr_History ).
SPLIT column AT `INTR_TABLE_CP_` INTO str sort_by.
CASE sort_by.
WHEN `OBJECT_ID`.
IF direction eq `00`. "ascending
SORT Int_Intr_History ASCENDING BY OBJECT_ID.
ELSEIF direction eq `01`. "descending
SORT Int_Intr_History DESCENDING BY OBJECT_ID.
ENDIF.
WHEN `PROCESS_TYPE`.
IF direction eq `00`. "ascending
SORT Int_Intr_History ASCENDING BY PROCESS_TYPE_TXT.
ELSEIF direction eq `01`. "descending
SORT Int_Intr_History DESCENDING BY PROCESS_TYPE_TXT.
ENDIF.
WHEN `DESCRIPTION`.
IF direction eq `00`. "ascending
SORT Int_Intr_History ASCENDING BY DESCRIPTION.
ELSEIF direction eq `01`. "descending
SORT Int_Intr_History DESCENDING BY DESCRIPTION.
ENDIF.
WHEN `CONCATSTATUSER`.
IF direction eq `00`. "ascending
SORT Int_Intr_History ASCENDING BY CONCATSTATUSER.
ELSEIF direction eq `01`. "descending
SORT Int_Intr_History DESCENDING BY CONCATSTATUSER.
ENDIF.
WHEN `CATEGORY_TXT`.
IF direction eq `00`. "ascending
SORT Int_Intr_History ASCENDING BY CATEGORY_TXT.
ELSEIF direction eq `01`. "descending
SORT Int_Intr_History DESCENDING BY CATEGORY_TXT.
ENDIF.
WHEN `DATE_START`.
IF direction eq `00`. "ascending
SORT Int_Intr_History ASCENDING BY POSTING_DATE.
ELSEIF direction eq `01`. "descending
SORT Int_Intr_History DESCENDING BY POSTING_DATE.
ENDIF.
WHEN OTHERS.
exit.
ENDCASE.
Node_Intr_History->BIND_TABLE( Int_Intr_History ).
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.