cancel
Showing results for 
Search instead for 
Did you mean: 

WITHIN THE SAME ALV GRID : INPUT FIELD / TEXT VIEW

Former Member
0 Kudos

Wihin one column is it possible to have some cell as input fields, some as text view ?

regards

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Yes, you have mutliple Cell Editors and control which cell editor is active based upon an attribute binding.

Former Member
0 Kudos

Could you be more specific ?

Example maybe ?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Well first of all if you just want to switch between input enabled input field and one that isn't input enabled, I would suggest going an easier route and just binding to the readOnly property. Why actually switch between InputField and TextView.

However it is possible to switch between different UI elements at the cell level. You have to create more than one cell variant for a column. Look at the help for the tableColumn property selectedCellVariant:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/85/48a841c1dae034e10000000a1550b0/frameset.htm

You data binding the selectedCellVariant to a context attribute and the value in this attribute controls which of the column cell variants will be used for that particular value.

Here is also the help for the TableStandardCell (the UI element child of the Table Column you create to make alternative cell variants):

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/56/5e9041d3c72e7be10000000a1550b0/frameset.htm

Answers (2)

Answers (2)

Former Member
0 Kudos

Hey!

Yes,you can use input field,text view ,link,checkbox or button and so on in column of the same alv gird.

Sample of code:


  DATA: LR_CMP_USAGE           TYPE REF TO IF_WD_COMPONENT_USAGE,
        LR_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,
        LR_CONFIG_TABLE        TYPE REF TO CL_SALV_WD_CONFIG_TABLE,
        LR_SALV_SETTINGS       TYPE REF TO IF_SALV_WD_TABLE_SETTINGS,
        LR_COLUMN              TYPE REF TO CL_SALV_WD_COLUMN,
        LR_INPUTFIELD          TYPE REF TO CL_SALV_WD_UIE_INPUT_FIELD,
        LR_TEXTVIEW            TYPE REF TO CL_SALV_WD_UIE_TEXT_VIEW.

  LR_CMP_USAGE = WD_THIS->WD_CPUSE_ALV_GRID( ).
  IF LR_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
    LR_CMP_USAGE->CREATE_COMPONENT( ).
  ENDIF.
  LR_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV_GRID( ).
  LR_CONFIG_TABLE = LR_INTERFACECONTROLLER->GET_MODEL( ).
  LR_SALV_SETTINGS ?= LR_CONFIG_TABLE.

  CALL METHOD LR_SALV_SETTINGS->SET_READ_ONLY
    EXPORTING
      VALUE  = ABAP_FALSE.

  LR_COLUMN = LR_CONFIG_TABLE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'LUGGWEIGHT' ).
  CREATE OBJECT LR_INPUTFIELD
    EXPORTING
      VALUE_FIELDNAME = 'LUGGWEIGHT'.
  CALL METHOD LR_INPUTFIELD->SET_READ_ONLY
    EXPORTING
      VALUE  = ABAP_FALSE.
  CALL METHOD LR_INPUTFIELD->SET_ALIGNMENT
    EXPORTING
      value  = CL_WD_ABSTRACT_INPUT_FIELD=>E_ALIGNMENT-CENTER.
  CALL METHOD LR_COLUMN->SET_CELL_EDITOR
    EXPORTING
      VALUE  = LR_INPUTFIELD.

  LR_COLUMN = LR_CONFIG_TABLE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'SMOKER' ).
  CREATE OBJECT LR_TEXTVIEW.
  CALL METHOD LR_TEXTVIEW->SET_TEXT_FIELDNAME
    EXPORTING
      VALUE  = 'SMOKER'.
  CALL METHOD LR_TEXTVIEW->SET_DESIGN
    EXPORTING
      VALUE  =  CL_WD_TEXT_VIEW=>E_DESIGN-EMPHASIZED.
  CALL METHOD LR_TEXTVIEW->SET_SEMANTIC_COLOR
    EXPORTING
      VALUE  =  CL_WD_TEXT_VIEW=>E_SEMANTIC_COLOR-NEGATIVE.
  CALL METHOD LR_COLUMN->SET_CELL_EDITOR
    EXPORTING
      VALUE  = LR_TEXTVIEW.

Former Member
0 Kudos

I know how to set a column as input field, anotherone as text view !

The point in in 1 and only one... for different rows, to have differences!

Former Member
0 Kudos

Hi Stephan,

here is a document explains how make columns editable

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

Regards,

Abdul