on 11-25-2005 8:35 AM
Hi All,
Is it possible to make a field input enabled on ALV Grid in version 4.6 B
If it is possible could you please let me know as to what needs to be done inorder to make a field input enabled.
Thanks & Regards,
Rahul.
Yes its possible in 4.6B.
Making ALV Grid Editable
This may be one of the mostly-used functionalities of the ALV Grid since as a
developer we prefer to use an ALV Grid instead of a table control for some reasons
that are known by all of you (at least for the sake of appearance). In fact, making the
ALV Grid editable has nothing to do with events. However, since controlling data
input which is explained in the next section is related, it is better that we deal with this
topic here.
To make a column editable, it will be sufficient to set the field EDIT in the
field catalog. The ALV Grid perceives if there are some editable fields and adds
buttons for editing purposes. If you do not need these new buttons, you know how to
exclude them.
To make individual cells editable, we will utilize the table we used for making
a cell a pushbutton. As you remember, it was of type LVC_T_STYL. If you have not
added this inner table, add it now. For this procedure; add the name of the field to the
field FIELDNAME, and pass cl_gui_alv_grid=>mc_style_enabled to make a
field editable and cl_gui_alv_grid=>mc_style_disabled to make a field noneditable,
to the field STYLE. You can use the one with disable when you make an
entire column editable and want just a few of cells along it non-editable. As you
remember from the pushbutton section we must tell the layout about this styling field.
e.g. ps_layout-stylefname = CELLSTYLES .
Now, lets solidify the procedure by code parts below. We want our column
SEATSMAX entirely editable except the case CARRID is XY which is a rare case
and we want our cells along the column PLANETYPE editable if their respective
CONNID fields contain the value 02.
Assume we have added our style table (CELLSTYLES) to our list data table
and tell the layout structure about it and we adjust the field catalog so that the column
SEATSMAX has the property EDIT set to X.
FORM adjust_editables USING pt_list LIKE gt_list[] .
DATA ls_listrow LIKE LINE OF pt_list .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
LOOP AT pt_list INTO ls_listrow .
IF ls_listrow-carrid = 'XY' .
ls_stylerow-fieldname = 'SEATSMAX' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled .
APPEND ls_stylerow TO lt_styletab .
ENDIF .
IF ls_listrow-connid = '02' .
ls_stylerow-fieldname = 'PLANETYPE' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled .
APPEND ls_stylerow TO lt_styletab .
ENDIF .
INSERT LINES OF lt_styletab INTO ls_listrow-cellstyles .
MODIFY pt_list FROM ls_listrow .
ENDLOOP .
ENDFORM .
Code Part 33 Conditionally setting fields to be editable or non-editable
As usual, cell based settings override entire column settings. You can
dynamically switch between cases in any proper part of your execution. Just fill your
inner table as required and refresh table display; for entire column settings, set or
unset the property EDIT of the field catalog for the column and reset the field
catalog using set_frontend_fieldcatalog.
As the last condition to be met for editability, you must call the method
set_ready_for_input passing 1 to the parameter i_ready_for_input.
Using this method you can switch between editable and non-editable mode. As
you guess, passing 0 to the parameter while calling the method, switches to noneditable
mode.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.