cancel
Showing results for 
Search instead for 
Did you mean: 

a question about the read_only property of table

Former Member
0 Kudos

Hi ,

I m trying :

in a table,only the selected row is input enabled,other rows should be dynamically deactivated.

is this idea possible to realize ?

best regards.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi friends,

thanks for your answers.

I think you want to bind the 'readonly' property of the celleditor to an attribute of a context node,

and through changing the attribute of the context node to control if it is readonly.

But the 'readonly' property of the celleditor is for a column , not for a row, right?

So if you changed the attribute "readonly" in a context node, then the readonly property of COLUMN will be changed,but not the row.

Can you help me to understand what you mean?

Former Member
0 Kudos

Hi,

Yes exactly you are right.The cell editor is at column level only not at row level.But if you modify at column level means you are also modifying at the row too.If you want to make editable of a row on click of lead selection then apply READONLY value to all the cell editors of a column.For your better understanding i am providing a code for you.

Create a context attribute READONLY of type ABAP_BOOL.

Create an Event handle method for on action of lead selection.In that read the data of selected row for that use code wizard and also get the index of that row.

now moodify the structure like

stru_sflight-readonly = abap_false.

modify lt_sflight from stru_sflight index lv_index transporting readonly.

then bind the internal table.

Now to make editable an entire row write the below code.

lt_columns =

l_table->get_columns( ).

loop at lt_columns into ls_columns.

  • create input field for columns

l_column1->bind_read_only( 'SFLIGHT.READONLY' ).

endloop.

Former Member
0 Kudos

Hi,

Thanks for your reply.

on the basis of your idea I guess I will get the end effect:

when I change the lead selection,then the readonly property of the column(say column A) will also be changed,so of course the readonly property of the row in the column A will also be changed.

if I have misunderstood ,pl correct me.

Here is my needs:

I have a table which has 5 columns. Two of the 5 columns are inputfields, the other columns are just textview. The effect that I want is to dynamically set only the inputfield of the selected row NOT READONLY and all the other inputfields READONLY .

with your idea i can still not get the point how to handle my problem. Can you pl explain me further?

Thanks

best regards

uday_gubbala2
Active Contributor
0 Kudos

Hi,

You can try proceed as follows.

1) Create an attribute of type WDY_BOOLEAN (say VISIBILITY) under the same node which you use for binding to your table ui element. Checkmark the "READONLY" checkbox for this attribute.

2) Go to the cell editor of each table column and bind the cell's READONLY attribute to the context attribute created earlier. (VISIBILITY attribute)

3) Now in the WDDOINIT method write the code for filling the table with data & for making all the rows of the table as readonly.

NOTE: I have taken the lt_mara, wa_mara, selected_row as attributes at view level. Please find their corresponding definitions as below.

lt_mara type IG_COMPONENTCONTROLLER=>ELEMENTS_MARA

wa_mara type IG_COMPONENTCONTROLLER=>ELEMENT_MARA

selected_row type i

METHOD wddoinit .
  DATA: lv_node TYPE REF TO if_wd_context_node,
        selected_row TYPE i VALUE 0.

  SELECT matnr
         ersda
         ernam
         mtart
         matkl
         meins FROM mara INTO CORRESPONDING FIELDS OF TABLE wd_this->lt_mara
                                 WHERE meins = 'GM' OR meins = 'CCM'.

  lv_node = wd_context->get_child_node( name = 'MARA' ).

  LOOP AT wd_this->lt_mara INTO wd_this->wa_mara.
    wd_this->wa_mara-visibility = 'X'.
    MODIFY wd_this->lt_mara FROM wd_this->wa_mara TRANSPORTING visibility.
  ENDLOOP.

  lv_node->bind_table( new_items = wd_this->lt_mara ).
ENDMETHOD.

4) Associate an action (say ONLEADSELECT) with the tables lead selection. In the event handler for this action ONACTIONONLEADSELEC write the code for setting the row selected as editable and the others as readonly.

method ONACTIONONLEADSELECT .
  DATA: lv_node TYPE REF TO if_wd_context_node.

  lv_node = wd_context->get_child_node( name = 'MARA' ).

  wd_this->selected_row = lv_node->get_lead_selection_index( ).

  LOOP AT wd_this->lt_mara INTO wd_this->wa_mara.
    wd_this->wa_mara-visibility = 'X'.
    MODIFY wd_this->lt_mara FROM wd_this->wa_mara TRANSPORTING visibility.
  ENDLOOP.

  READ TABLE wd_this->lt_mara INTO wd_this->wa_mara INDEX wd_this->selected_row.
  wd_this->wa_mara-visibility = ' '.
  MODIFY wd_this->lt_mara INDEX wd_this->selected_row FROM wd_this->wa_mara TRANSPORTING visibility.
  lv_node->bind_table( new_items = wd_this->lt_mara ).
ENDMETHOD.

Hope this helps answer your question.

Regards,

Uday

Former Member
0 Kudos

Hi

It is completely possible to realize, here are the steps to follow to make this happen: ( This is only up to my knowledge, if any one suggest any easy / better process you can go with that )

1. In the context node, where you have your table data, create a new attribute of type WDY_BOOLEAN, say READ_ONLY and when you fill the context, fill this attribute with 'X'

2. When you create the table binding to the table element on the View, choose the Cell Editor as Input Field

3. Then the Table node will generate all the columns in the table element.

4. Each Column will have Value and Label, so for your requirement, you need to bind the readOnly attribute to the newly created READ_ONLY attribute of the table context.

5. Next step is to create a event for onLeadSelect for the table.

6. With in this event, you need to read the table context and make the READ_ONLY attribute for all the rows again 'X' and mark ' ' for the lead select.

7. The purpose of making all the row 'X' is because, when you change the row selection on table, it should set back the row to read only.

8. So with this approach, you can set the entire row as editable, or only selected columns of the row as editable(if you create multipe read_only attributes.

Let me know if you have any question on the approach

Regards,

Trikanth