Skip to Content
author's profile photo Former Member
Former Member

Edit a single row in a table

Hi All,

I have a requirement to display a table in the non editable mode intially. The user when selects a row and selects a button(EDIT) the selected row should be editable.

Also When add row button is clicked it should add an empty row and the user should be able to add new records in the table.

Please let me know how this can be achieved.

Thanks for the help.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 19, 2008 at 08:23 AM

    Build your table with input fields.

    Your table is bound to your context node.

    your context node is populated by a supply method.

    In the supply method, add every line seperately. (node->add_element ) (this returns an element object which you will need)

    set the properties for the element (every field in the node has some properties, among which read_only) (element->setprop something)

    bind the read_only property of your input fields to the respective read_only property of your context attribute (look at the special option, bind property in the binding popup)

    as a result you will now have an editable table with all fields ineditable.

    now when you select an element in the table and press edit, you can retrieve the selected element (node->get_lead_selection or node->get_selection_collection, or ... something similar, see what best fits your needs.)

    for the retrieved element(s) set the properties again (element->setprops something..)

    specifically turn off the read_only property.

    As an extra tip here: Do NOT have existing keyfields editable. In other words, check if the record existed already in the database. If yes, keep the key fields read_only. if not, you can have them editable.

    same goes for adding a row. you push the button add.

    the code simply adds an empty element to the node (node->add_element) and you leave all properties blank (which they are by default, so no extra work there)

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2008 at 09:18 AM

    Hi,

    Do this way....

    1.When you click on the EDIT the selected row should be editable.

    Take an attribute READONLY type ABAP_BOOL and this attribute to READ ONLY property of your table.

    write event handler method for EDIT buton action.here read your context node use GET_STATIC_ATTRIBUTES method to receive the selected row information.

    Now modify your internal table with readonly value is ABAP_FALSE.

    thats all your selected row will be in Editable.

    2.When add row button is clicked it should add an empty row and the user should be able to add new records in the table.

    do same as above

    Thaks

    Suman

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.