on 06-24-2009 6:04 PM
Hi,
I am working on this ALV events tutorial [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/bd28494a-0801-0010-45a3-fc359d82d3e8 ].I have completed it and works fine.Now I am trying to enhance it.
Where I provide a check box column and if users checks it PRICE column should become editable.
For this
1-I have created attribute READ_ONLY of type BOOLEAN under same context node.
2-Created Checkbox for that attribute READ_ONLY & output has checkbox column now.
I tried creating ONCLICK -event handler -event-ON_CELL_ACTION and wrote following code .
when I debug it is not even comming into this method.
METHOD onclick .
DATA:lt_columns TYPE salv_wd_t_column_ref,
ls_columns TYPE salv_wd_s_column_ref.
DATA: l_column_settings TYPE REF TO if_salv_wd_column_settings.
lt_columns = l_column_settings->get_columns( ) .
LOOP AT lt_columns INTO ls_columns .
CASE ls_columns-id.
WHEN 'PRICE'.
* Create Editable cell
DATA: l_input_field TYPE REF TO cl_salv_wd_uie_input_field.
CREATE OBJECT l_input_field
EXPORTING
value_fieldname = ls_columns-id.
ls_columns-r_column->set_cell_editor( l_input_field ) .
" binding the attribute to the read only property
l_input_field->set_read_only_fieldname( 'READ_ONLY' ).
ENDCASE.
ENDLOOP.
ENDMETHOD.
What am I doing wrong.
I even tried it with ON_DATA_CHECK & ON_CLICK.
Rgds
Vara
Edited by: Vara K on Jun 24, 2009 7:05 PM
*** This eventhandler method gets triggered for any changes that the user might make to
*** the ALV so we first need to check if the changes have been made to the column CHECK or
*** something else
LOOP AT r_param->t_modified_cells INTO wa_modified_data.
CASE wa_modified_data-attribute.
WHEN 'CHECK'.
lv_index = wa_modified_data-index.
READ TABLE lt_sflight INTO wa_sflight INDEX lv_index.
*** We need to check if the checkbox is checked/unchecked by the user
ASSIGN wa_modified_data-r_value->* TO <fs>.
*** If it is checked then we need to make the 2 date columns as editable
IF <fs> = 'X'.
wa_sflight-date_enabled = ''.
*** If it is unchecked then we need to make the 2 date columns as non-editable
ELSE.
wa_sflight-date_enabled = 'X'.
ENDIF.
MODIFY lt_sflight FROM wa_sflight INDEX lv_index TRANSPORTING date_enabled.
WHEN 'D1'.
lv_index = wa_modified_data-index.
READ TABLE lt_sflight INTO wa_sflight INDEX lv_index.
ASSIGN wa_modified_data-r_value->* TO <fs>.
wa_sflight-d2 = <fs> + 7.
lv_date1 = <fs>.
wa_sflight-d2 = lv_date1 + 7.
MODIFY lt_sflight FROM wa_sflight INDEX lv_index TRANSPORTING d2.
ENDCASE.
ENDLOOP.
*** Bind the context node with the new modified internal table
wd_node->bind_table( new_items = lt_sflight ).
CLEAR lt_sflight.
CALL METHOD wd_node->get_static_attributes_table
EXPORTING
from = 1
to = 2147483647
IMPORTING
table = lt_sflight.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Uday,
Thank you very much for the very detailed explanation.
I have done exactly what you have suggested.
I have placed a break-point on 2 methods. After I check the box it is stoppoing at first method wddoafteraction but it is not entering in to ON_DATA_CHECK event method.
Read_only is of type char1( this is the column with checkboxes)
It is behaving like changes are not done.I have Wdoinit as below.
DATA: lr_checkbox TYPE REF TO cl_salv_wd_uie_checkbox.
lr_column = l_value->if_salv_wd_column_settings~get_column( 'READ_ONLY' ).
CREATE OBJECT lr_checkbox
EXPORTING
checked_fieldname = 'READ_ONLY'.
lr_checkbox->set_enabled( abap_true ).
lr_column->set_cell_editor( lr_checkbox ).
* set read only mode to false (and display edit toolbar)
DATA: lr_table_settings TYPE REF TO if_salv_wd_table_settings.
lr_table_settings ?= l_value.
lr_table_settings->set_read_only( abap_false ).
What could be the reason?
Rgds
vara
Uday: I am sending you an e-mail with the full-code which I have may be that will help identifying the issue.
Edited by: Vara K on Jun 25, 2009 10:03 PM
I have created an event handler method IF_DATA_CHANGED for the event ON_DATA_CHECK which gets triggered when any data is changed in the ALV. Now within this event handler method I check as to where the event gets triggered from. Suppose the data change is triggered by:
1) Toggling the checkbox then I want the corresponding columns D1 & D2 of that row to be enabled.
2) If the user has entered any data in the editable D1 field & pressed on enter then I want D2 to be filled with a date 7 days after the date entered by the user.
Below is the coding within my event handler method:
METHOD if_data_changed .
DATA: wa_modified_data TYPE salv_wd_s_table_mod_cell,
lv_index TYPE i VALUE 0,
lv_date TYPE date,
wd_node TYPE REF TO if_wd_context_node,
lt_sflight TYPE wd_this->elements_sflight,
wa_sflight TYPE wd_this->element_sflight.
DATA : lv_date1 TYPE sydatum.
FIELD-SYMBOLS: <fs> TYPE data.
wd_node = wd_context->get_child_node( name = 'SFLIGHT' ).
*** Fetch all the data currently being displayed in the ALV
CALL METHOD wd_node->get_static_attributes_table
EXPORTING
from = 1
to = 2147483647
IMPORTING
table = lt_sflight.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I first capture the toggling of the checkbox through the coding in WDDOAFTERACTION as how shown below:
METHOD wddoafteraction .
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
lo_interfacecontroller->data_check( ).
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vara,
Try going this sample code snippet below in which I am displaying data from SFLIGHT in an ALV. I have a column (CHECK) being displayed as checkboxes. I have 2 other date columns ( D1 & D2 ) also being displayed in the ALV. If the user checks the checkbox in column CHECK, I want the 2 date fields D1 & D2 of that corresponding row to be enabled for entry.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vara,
As how mentioned in the tutorial the ON_CLICK event is triggered when an action on a column holding a non editable cell editor (Button, ToggleButton, LinkToAction) is performed (ButtonClick, LinkClick). So this event wouldn't help your cause for working with a CheckBox.
You can try proceed as follows. Do a check if any data has changed within your ALV within the WDDOAFTERACTION method like below:
METHOD wddoafteraction .
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
lo_interfacecontroller->data_check( ).
ENDMETHOD.
So if any data has changed (if the user toggles the checkbox then it results in a data change) then the ON_DATA_CHECK event gets triggered. So create an event handler method for this event and do your desired coding within this particular event handler method.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.