cancel
Showing results for 
Search instead for 
Did you mean: 

problem in editing row of a table

Former Member
0 Kudos

Hi All,

My requirement is when i am selecting one row of a table and click on edit button the row should be enabled and remaininig rows should be disabled.This is working fine But when i again select another row of same table and clicking the edit button that particular row changes to editable mode.But i am unable to disable the previousely selected row.Can anybody give me idea to diaable the previously selected record.

In this scenario i used one attribute of type wdy_boolen for binding it to the read-only property of input field in a table.In action of button i am getting the leadselection of row and depending on the lesd selection written the logic for enabling the row using set_attribute method.

Please help me............

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi:

Since you are able to edit the particular cell and at the same time, the rest of cell would remain disbable , is sound good.

Only one thing you should do to refresh the process.

Regards

Shashi

uday_gubbala2
Active Contributor
0 Kudos

Try proceed as follows.

Suppose you are displaying 3 columns col1, col2 & col3 in your table then create an additional attribute at context level say ATTR4 of type WDY_BOOLEAN. And specify the default value for this attribute at context level as true i., X . So now when you display the data in the table all rows have an additional boolean attribute ATTR4 which has a value of true. Now go to the individual cell editor of each table column and bind its readOnly property to this created attribute ATTR4. So now the tables row would be editable/non-editable based on the value contained in ATTR4.

Now create an event on leadSelection for the table and within this eventhandler:

1) Get the index of the row selected by the user.

2) Modify the value of context attribute ATTR4 for this particular index to a blank value i.e, false.

ex: If table has 10 rows and user has clicked on the 3rd row then you will need to modify the 3rd index value of ATTR4 at context node.

Since the table rows readOnly property are bound to this ATTR4, the 4th row would be having the value as false which would result in only the 4th row being displayed as editable. Hope this helps resolve your problem.

Regards,

Uday

uday_gubbala2
Active Contributor
0 Kudos

Hi Srilalitha,

Just create the standard cell editors of the table control as, "Input Fields" instead of the normal 'TextView". (This can be done as follows... When you right click on the table UI element (under ROOTUIELEMENTCONTAINER) & say "Create Binding" you have the, "Standard Cell Editor" & "Standard Property" fields. Set "Standard Cell Editor" to "InputField" & "Standard Property" to "Value") Create a boolean attribute at component controller level & bind it to the readOnly property of the Table. Dont create this attribute under the same node which you are using to bind to your table. This variable value would then stand true for all the cells under this column. So suppose if you have 4 columns in the table then bind all the 4 columns readOnly attribute to the same boolean variable that you have created. Now place a button & create an eventhandler for the same. Now within this method set true & false ( ) values for this boolean attribute to switch between editable & non-editable modes for the table.

If you however create it under the same node which you are using to bind your table then each cell of the column can have different true/false values resulting in different editable features.)Then within the WDDOINIT method you can You will then get the output as how desired.

Consider the code fragment below. It would result in all the fields which have the MEINS value equal to GM as read only & the rest would be editable. Hope this is clear to you now.

METHOD wddoinit .
  DATA: lv_node TYPE REF TO if_wd_context_node,
        lt_mara TYPE ig_componentcontroller=>elements_mara,
        wa_mara TYPE ig_componentcontroller=>element_mara.
 
  SELECT matnr
         ersda
         ernam
         mtart
         matkl
         meins FROM mara INTO CORRESPONDING FIELDS OF TABLE lt_mara
                                 WHERE meins = 'GM' OR meins = 'CCM'.
  SORT lt_mara BY meins.
 
  lv_node = wd_context->get_child_node( name = wd_this->wdctx_mara ).
  LOOP AT lt_mara INTO wa_mara.
    IF wa_mara-meins = 'GM'.
      wa_mara-readonly = 'X'.
    ELSE.
      wa_mara-readonly = ' '.
    ENDIF.
    MODIFY lt_mara FROM wa_mara TRANSPORTING readonly.
    lv_node->bind_structure(  SET_INITIAL_ELEMENTS = ABAP_FALSE
                              new_item = wa_mara ).
  ENDLOOP.
 
  lv_node->bind_table( new_items = lt_mara ).
ENDMETHOD.

Regards,

Uday

Former Member
0 Kudos

Hi Srilalitha yerr... ,

Easy way is Allow edit to entire table & then make it all readonly after final changes are done. This is easily achievable if you have READ-ONLY attribute bound to TABLE UI ELEMENT at Table Element level.

Other way is to have method MAKE_TABLE_READ_ONLY( ) this will make entire table read only.

When you define method on click of particular row the

a) call this method MAKE_TABLE_READ_ONLY( ).

b) get the index of the ROW selected either by OnLeadSelection event of that table or from the EVENT Object thats passed to know the index line...

Once you know the Index of table thats clicked on

Modify the Internal table thats binded at iIndex change the parameter to READ-ONLY False.

Once the user clicks on different row..because of call to MAKE_TABLE_READ_ONLY( ) at first step all rows are made read-only again.

Cheers

Prashant

Former Member
0 Kudos

Hi,

What you can do is, in the OnLeadSelection event of that table set the attribute binded to the read only property of the table to abap_false and bind it to the node.

Now when you select any row the entire table will be in read only mode and then if you press the edit button,lead selected row will be in editable mode.

thanks,

Subhasis

Former Member
0 Kudos

Hi subhasis,

Thanks for ur reply.How can we bind the attribute set by set_attribute method to the node.Plz send me the code for this................

Edited by: srilalitha yerramsetti on Feb 9, 2009 2:11 PM

former_member226203
Active Contributor
0 Kudos

think u can use and set the method set_read_only of class IF_SALV_WD_TABLE_SETTINGS to abap_true to make ur change.

u can chk this link which has the details for columns:

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0155eb5-b6ce-2b10-3195-d9704982...

Edited by: Kalyan Chakravarthi on Feb 6, 2009 1:29 PM