cancel
Showing results for 
Search instead for 
Did you mean: 

Make table Read Only on Click event

Former Member
0 Kudos

Dear Webdynamites,

I'm stuck at one issue. My requirement is to display the z table data in a table on the window, on click of a link. Depending on one condition, the table should display the data in Read Only mode. And on click of an "ADD" button on the screen only one row should be appended on the table and after the "SAVE" button is pressed it should again come back to the display mode with all the buttons active.

I'm able to display the data in Editable mode, but not able to do the same to display in non-editable mode.

My table includes InputFields as rows and columns.

Kindly requested to send your suggestions for the same. Helpful Answers would be surely awarded.

Thanks in anticipation,

Regards,

-Syed.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Wahid,

Ensure that internal table has a column with of type Boolean( lets call this column col_read_flag ). Infact

if you are using Ztable you can very well have column of this type in ur z-table.When you bind the internal table to, UI element table, bind the property READ ONLY with the value in col_read_flag from

the node, for all the columns of your table.

By default before displaying your table fill 'X' in columne col_read_flag for all rows in your internal table

thus , entire table on UI would appear read-only when applicataion is executed.

for ADD fucntionality, OnActionAdd you can write code to create a NEW element for this table and set

the property of attribute "col_read_flag" eq ABAP_FALSE. Thus last row would appear as edidateble.

On Save, onActionSave Get this element via LeadSelect & set its col_read_flag equal to ABAP_TRUE thus ur entire table is again read only!!

code- for ON ADD

node_data is the internal table thats binded to your TABLE UI ELEMENT.

DATA:
      node_data                           TYPE REF TO if_wd_context_node,
      elem_data                           TYPE REF TO if_wd_context_element,
      stru_data                           TYPE if_componentcontroller=>element_data .
*   navigate from <CONTEXT> to <DATA> via lead selection
    node_data = wd_context->get_child_node( name = if_componentcontroller=>wdctx_data ).

*   @TODO handle not set lead selection
    IF ( node_data IS INITIAL ).
      return.
    ENDIF.
  
    CALL METHOD node_data->create_element
      receiving
        element                 = elem_data.
    
    CALL METHOD elem_data->set_attribute
      EXPORTING
        VALUE  = abap_false
        name   = 'col_read_flag'.
    
    CALL METHOD node_data->bind_element
      EXPORTING
        NEW_ITEM             = elem_data
        SET_INITIAL_ELEMENTS = ABAP_TRUE.

-Code On Save.

get the last item added and set

CALL METHOD elem_data->set_attribute
      EXPORTING
        VALUE  = abap_true
        name   = 'col_read_flag'.

Greetings

Prashant

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks,

The problem is solved.

Regards,

-Syed.

Former Member
0 Kudos

Hi Wahid,

just add a read_only-attribute to your context-structure ( type wdy_boolean e.g. ). Afterwards you can bind the readonly flag of your inputfields to this attribute.

Now you can define the accessibility of each row in your table.