cancel
Showing results for 
Search instead for 
Did you mean: 

Inserting a User enabled row On click of a button

Former Member
0 Kudos

Hi Gurus,

I have a Table Ui element on which i have an "Insert" button on its tool bar.

There are Text view rows already in the table.

Now when i hit "Insert" button then an empty row should be attached to the 1st index of the table in which the user can enter the values.

Thanks in Advance

Accepted Solutions (1)

Accepted Solutions (1)

saravanan_narayanan
Active Contributor
0 Kudos

Hello,

with Text View as Table Cell Editor, you can not input/enter any data. you should change the Table Cell Editor to Input Field UI element.

Since you want existing rows in the table to be readonly, create an boolean attribute in the context node (Table's datasource node) and bind the same to the readonly property of the Table Cell Editor (Input field here). For existing records set the boolean value to abap_true and for the new records set the value to abap_false.

Another solution would be to go with the cell variant where you need to create two cell variants one with Input field and another with text view and dynamically binding the cell variant to the table column.

BR,

Saravanan.

former_member199125
Active Contributor
0 Kudos

Hi Sarvanan,

How can we set readonly property to particular row? i dont know how can you set for particualr row.

As per your suggestion pls modify the below code.. so that shravan can understand easily.

LO_ND_N_TABLE->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = IT_TABLE ).

  • Insert one row into internal table.

APPEND WA_TABLE TO IT_TABLE.

  • Enabling the next row of the table.

LO_ND_N_TABLE->BIND_TABLE( new_item = IT_TABLE

set_initial_elements = abap_false

index = 1 ).

lo_nd_n_table->set_attribute ( exporting name = ''boolean attribute name "

value = abap_false ).

now if you set the boolean attribute to abap_false, then it will apply to all rows. am i right?

Thanks and Regards

Srinivas

Former Member
0 Kudos

Hi

When I try to insert a row into the internal table and then binding it the row that is being inserted is depending on the

already present rows.

What i meant to say is if the rows are text views then the same is being inserted and if they are input enabled then Input enabled row is being inserted.

As Saravanan said if we take an attribute and set that accordingly I am a bit confused how to set that to a single row.

Could you guys please dig in a bit and expalin in detail.

THANKS in Advance

Former Member
0 Kudos

Hi,

1 Create a context attribute as wdy_boolean in the node to whcih the table is bound.

2 Now when you create a table UI element create all the cell editors as Input field type.

3 Now bind the READ_ONLY property of each input field to this read_only context attribute for all the cells.

4 First time when you display the data,

LOOP AT ITAB INTO wa_tab.

wa_itab-read_only = abap_true. "Disable

modify the internal table.

ENDLOOP.

5 Bind this internal table to the Node.

6. In insert button, when you add the row, pass the value to thie READ_ONLY attribute as abap_false ie Enable.

whcih enales as input for that entire row.

Hope this is clear.

Regards,

Lekha.

saravanan_narayanan
Active Contributor
0 Kudos

As Saravanan said if we take an attribute and set that accordingly I am a bit confused how to set that to a single row.

Could you guys please dig in a bit and expalin in detail.

you need to bind this attribute to the Read Only property of each Table Cell Editor(Input field/Text View) in the table

BR,

Saravanan

Former Member
0 Kudos

Hi Lekha,

When i am trying to set the read-only attribute as disabled then all the rows are user enabled.

Is it possible to do that to the row that is being inserted.

Thanks & Regards,

Shravan

Former Member
0 Kudos

Hi

When you insert a row, you might be passing that sturcutre right in that sturcture pas the READONLY value as abap_false for editablility. INSERT button click event you need to write the code.

First time display irrecpective of the rows/index, set the read_only attribute as abap_true and modify the table.

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi.,

You have to Add Input View in Table not Text View.,

and when click of button .,

  • Importing the values of the corresponding node

LO_ND_N_TABLE->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = IT_TABLE ).

  • Insert one row into internal table.

APPEND WA_TABLE TO IT_TABLE.

  • Enabling the next row of the table.

LO_ND_N_TABLE->BIND_TABLE( IT_TABLE ).

hope this helps u.,

Thanks & Regards,

Kiran

Former Member
0 Kudos

Hi Kiran

Thanks For the response.

Here i want the row which s gonna come after i hit "insert" only as user enabled.

Rest of the rows which were already present should be in read only mode.

Hope you understud my problem...

Former Member
0 Kudos

Hi Shravan,

In onaction of your button write this code...

data: lo_nd_details type ref to if_wd_context_node,
        ls_details type wd_this->element_details,
        lo_new_element type ref to if_wd_context_element.
 
  lo_nd_details = wd_context->get_child_node( name = wd_this->wdctx_details ).
 
* append a line to the node
  lo_new_element =  lo_nd_details->bind_structure( new_item = ls_details
                                  set_initial_elements = abap_false
                                  index = 1 ).

// this record is adding at index 1 , if you want you can insert based on index.

Please check this to insert desired position.

Cheers,

Kris.