on 09-29-2008 1:11 PM
Hello,
I created an editable empty table with dynamic columns. But now only the first row of this table is editable. Do anybody know what's the problem??
Regards,
Mario
Hello,
no, i want an empty table in which all rows are editable.
Regards,
Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mario,
Then it is very simple.
You can do in 2 ways.
First way
1.go to columns of table right click on that and select remove cell editor again right click on column now select insert cell editor, a pop up will appears ask you to enter id and type of field.Enter Id and select Input field from drop down.
repeat the same for all the columns thats all your table will be editable when you run the application.
Second Way
1. create a context attribute READ_ONLY of type ABAP_BOOL in your context node attributes.
2.populate the above attribute with value abap_true like below.
loop at lt_flight into ls_flight.
ls_flight-readonly = abap_true.
modify lt_flight from ls_flight transporting readonly.
endloop.
3.Now modify the cell editors of columns means change the cell editor of column to editable.
Note: Write below code in the Method WDDOMODIFYVIEW
lr_info = node_sflight->get_node_info( ).
lr_nodeinfo = lr_info->get_attributes( ).
loop at lr_nodeinfo into ls_nodeinfo.
concatenate 'SFLIGHT.' ls_nodeinfo-name into fs_name-str.
append fs_name to lt_name.
endloop.
lr_info = node_sflight->get_node_info( ).
lr_nodeinfo = lr_info->get_attributes( ).
loop at lr_nodeinfo into ls_nodeinfo.
concatenate 'SFLIGHT.' ls_nodeinfo-name into fs_name-str.
append fs_name to lt_name.
endloop.
lr_info = node_sflight->get_node_info( ).
lr_nodeinfo = lr_info->get_attributes( ).
loop at lr_nodeinfo into ls_nodeinfo.
concatenate 'SFLIGHT.' ls_nodeinfo-name into fs_name-str.
append fs_name to lt_name.
endloop.
lr_cols = lr_table->get_columns( ).
loop at lr_cols into lr_tbcol.
str1 = lr_tbcol->if_wd_view_element~get_id( ).
concatenate str1 '1' into str1.
lv_tabix = sy-tabix.
read table lt_name into fs_name index lv_tabix.
if sy-subrc = 0.
lr_input1 =
cl_wd_input_field=>new_input_field(
bind_value = fs_name-str "Node.attibute name to be bound
enabled = abap_true
id = str1
* on_enter = ON_ENTER
* read_only = 'X'
* VIEW = VIEW
).
lr_input1->bind_read_only( path = 'SFLIGHT.READONLY' ).
lr_tbcol->set_table_cell_editor( the_table_cell_editor = lr_input1 ).
endif.
clear str1.
clear fs_name.
clear lr_tbcol.
endloop.
Hi,
my problem is that only the first row is editable and i want that all rows are editable.
Regards,
Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mario,
You want first row is editable and the remaining rows are non editable am i right?
Please check the code in my previous code absolutely i wrote for single row editable.There i made 3rd is editable and remainig rows are non editable.To do this create a context attribute and populate that value like below.
loop at lt_flight into ls_flight.
if sy-tabix = '3'.
ls_flight-readonly = abap_false.
else.
ls_flight-readonly = abap_true.
endif.
modify lt_flight from ls_flight transporting readonly.
endloop.
Still you dont understand my code let me know..
Hi Mario,
To make first row editable you have to create another attribute READ_ONLY of type ABAP_BOOL in your context node.
Populate that attribute where ever you want to make the editable in your table and then read all the columns and change their cell editors to input fields and then bind the READ_ONLY attribute to the input fields.
Check the below to make the single row editable,here i made 3 rd row is editable and the remaining rows are non editable.
METHOD wddomodifyview .
TYPES:
BEGIN OF ty_name,
str TYPE string,
END OF ty_name.
DATA:
ls_flight TYPE if_main=>element_sflight,
lt_flight TYPE if_main=>elements_sflight,
node_sflight TYPE REF TO if_wd_context_node,
elem_sflight TYPE REF TO if_wd_context_element,
stru_sflight TYPE if_main=>element_sflight,
lr_table TYPE REF TO cl_wd_table,
lr_input TYPE REF TO cl_wd_input_field,
lr_input1 TYPE REF TO cl_wd_input_field,
lr_tbcol TYPE REF TO cl_wd_table_column,
lr_celledit TYPE REF TO if_wd_table_cell_editor,
lr_cols TYPE cl_wd_table_column=>tt_table_column,
lr_nodeinfo TYPE wdr_context_attr_info_map,
ls_nodeinfo TYPE wdr_context_attribute_info,
lr_info TYPE REF TO if_wd_context_node_info,
fs_name TYPE ty_name,
lt_name TYPE STANDARD TABLE OF ty_name,
str1 TYPE string,
lv_tabix TYPE sy-tabix.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE lt_flight UP TO 10 ROWS.
read table lt_flight into ls_flight index 3.
LOOP AT lt_flight INTO ls_flight.
IF sy-tabix = '3'.
ls_flight-readonly = abap_false.
ELSE.
ls_flight-readonly = abap_true.
ENDIF.
MODIFY lt_flight FROM ls_flight TRANSPORTING readonly.
ENDLOOP.
navigate from <CONTEXT> to <SFLIGHT> via lead selection
node_sflight = wd_context->get_child_node( 'SFLIGHT' ).
node_sflight->bind_table(
new_items = lt_flight
SET_INITIAL_ELEMENTS = ABAP_TRUE
INDEX = INDEX
).
lr_table ?= view->get_element( id = 'TBL_SFLIGHT' ).
lr_info = node_sflight->get_node_info( ).
lr_nodeinfo = lr_info->get_attributes( ).
LOOP AT lr_nodeinfo INTO ls_nodeinfo.
CONCATENATE 'SFLIGHT.' ls_nodeinfo-name INTO fs_name-str.
APPEND fs_name TO lt_name.
ENDLOOP.
**Eidtable single row****************
lr_cols = lr_table->get_columns( ).
LOOP AT lr_cols INTO lr_tbcol.
str1 = lr_tbcol->if_wd_view_element~get_id( ).
CONCATENATE str1 '1' INTO str1.
lv_tabix = sy-tabix.
READ TABLE lt_name INTO fs_name INDEX lv_tabix.
IF sy-subrc = 0.
lr_input1 =
cl_wd_input_field=>new_input_field(
bind_value = fs_name-str "Node.attibute name to be bound
enabled = abap_true
id = str1
ON_ENTER = 'ENTER'
read_only = 'X'
VIEW = VIEW
).
lr_input1->bind_read_only( path = 'SFLIGHT.READONLY' ).
lr_tbcol->set_table_cell_editor( the_table_cell_editor = lr_input1 ).
ENDIF.
CLEAR str1.
CLEAR fs_name.
CLEAR lr_tbcol.
ENDLOOP.
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.