Table UI element - dynamic cell editor change on runtime

Hello,
I have standard table UI element defined on one of the views as part of it's layout, two columns only - KEY and VALUE. Both defined as text cell editor by default. Content of the table is dynamic and different combination of keys and values are presented depending on the app context.
Recently the need arised to (depending on the key value) change the cell editor type for single rows only, dynamically from text to link to action - and to register a triggable event for that with some logic behind (to open new window when link is clicked).
Is it possible at all to have a column in Table UI element with different editor types set dynamically on runtime for different rows? Some cells then wolud still be presented as text, some would have a link to action in them.
If possible can I ask for any hints on how to achieve that?
I imagine that first I have to get somehow a reference to the UI element created when the view is triggered first time, then after I recieve values from backend but prior (or after?) binding it to the table context I would like to evaulate the keys and change cell editors accordingly. Then for changed editors (link to action) I would like to register triggable events (on action) which would call some custom methods for further processing. Please advice.
Best regards,
Marcin

Hi,
   You can use the cell variants to display different cell editors in different rows.
   First in your table column where you want to display different cell editors insert two cell variants
   and fill the VARIANT KEY for each cell variant and insert textview under one cell variant and input field
   under another cell variant, and bind the text to be displayed to these cell editors, now take an extra
   attribute of type string in your node and bind it to the table column property SELECTED CELL VARIANT.
   Now depending on your requirement change this attribute to any of the VARIANT KEY defined for cell variants. 
loop at itab into wa.
      if 'YOUR CONDITION'.
        wa-cellvar = 'VAR1'.                 "cellvar is the attribute which is bound to SELECTED CELL VARIANT
        else.                                          " of table column
          wa-cellvar = 'VAR2'.                 " VAR1 and VAr2 are the variant keys of cellvariants
          endif.
          modify itab from wa.
      endloop.
Hope this solves your problem.

Similar Messages

  • PLEASE HELP-JTable cell editor-change one cell, changes all cells of column

    for example i have 3 rows 4 columns, column 3 and 4 are dates. now if i change the date to a new value (eg for of column 3)
    for any row, and then i click on any other cell. All cell values ie all rows for that column are changed to that new value.
    ie it changed column 3 for all rows 1, 2 and 3 to that new value which i changed in only one cell of that column.
    PLEASE HELP me , tell me what change i make to the code to fix it ....
    this is my cell renderer for date
    class DateCellRenderer extends JbcDateTimeChooser implements TableCellRenderer {
      protected Border m_noFocusBorder;
      public DateCellRenderer() {
        super();
        setStylePattern(JbcDateTimeChooser.MEDIUM);
        m_noFocusBorder = new EmptyBorder(1, 2, 1, 2);
        setOpaque(true);
        setBorder(m_noFocusBorder);
      public Component getTableCellRendererComponent(JTable table,
       Object value, boolean isSelected, boolean hasFocus,
       int row, int column)
      if(value instanceof Date) {
          Date b = (Date)value;
          setDate(b);
        setFont(table.getFont());
        setBorder(hasFocus ? UIManager.getBorder(
          "Table.focusCellHighlightBorder") : m_noFocusBorder);
        return this;
    }I have this custom cell editor date
    class DateCellEditor extends AbstractCellEditor implements TableCellEditor {
      protected JbcDateTimeChooser editor;
      public DateCellEditor() {
        super();
        editor = new JbcDateTimeChooser();
        editor.setStylePattern(JbcDateTimeChooser.MEDIUM);
      public Object getCellEditorValue() {
        return editor.getDate();
      public Component getTableCellEditorComponent(JTable table,
       Object value, boolean isSelected, int row, int column)
        if(value instanceof Date) {
          editor.setDate((Date)value);
        return editor;
    }and this is how i defined in jtable
        lnnTableModel = new CellSiteLNNTableModel();
        lnnTable.setModel(lnnTableModel);
        lnnTableModel.addColumn("ABC");
        lnnTableModel.addColumn("DEF");
        lnnTableModel.addColumn("Date From");
        lnnTableModel.addColumn("Date To");
        for(int k = 0; k < lnnTableModel.getColumnCount(); k++) {
          TableColumn col = lnnTable.getColumn(lnnTableModel.getColumnName(k));
          TableCellRenderer renderer;
            DefaultTableCellRenderer textRenderer = new DefaultTableCellRenderer();
            renderer = textRenderer;
          TableCellEditor editor;
          JTextField textColumn = new JTextField();
          if((k == CellSiteLNN.DATE_FROM) || (k == CellSiteLNN.DATE_TO)) {
            editor = new DateCellEditor();  //  this is the cell editor
         renderer = new DateCellRenderer(); // this is the assigned cell renderer
          } else {
            editor = new DefaultCellEditor(textColumn);
          col.setCellRenderer(renderer);
          col.setCellEditor(editor);
        }

    table model is extended from AbstractTableModel
    and have these methods
    do you see anything wrong here.....
      public Object getValueAt(int row, int column) {
        Vector rowVector = (Vector)dataVector.elementAt(row);
        return rowVector.elementAt(column);
      public void setValueAt(Object aValue, int row, int column) {
        Vector rowVector = (Vector)dataVector.elementAt(row);
        rowVector.setElementAt(aValue, column);
        // generate notification
        fireTableChanged(new TableModelEvent(this, row, row, column));
      } // end method (setValueAt)

  • Creating a Cell Editor for a JTree

    Hi...
    I would like to be able to edit the nodes of a JTree dynamically, but I'm not sure how to do it. I have unsuccessfully tried to implement a celleditor by extended the DefaultTreeCellEditor. The editing works fine, but once the cell has been edited, I get a ClassCastException.
    I know that I need to get the edited value and then make appropriate changes to the DefaultMutableTreeNode object stored, but I am not sure where to do all this. I would really appreciate some tips on where to get the edited value entered, and how I can access the object being edited. Thanks.
    ..VJ..

    So, you have a big table whose cells each contain a little table. I assume you already have the little tables working correctly with cell editors and so on, and you want to write a cell editor for the big table. Correct?
    My problem with this is that I can't imagine how this would actually work in practice. Suppose I click on a cell in the big table; then the cell renderer displays the appropriate little table. At this point should I see one of the cells in that little table selected, and should I be able to use the Tab key to move around the little table? And if so, then I can't use the Tab key to move around the big table. Next, suppose I press F2 indicating that I want to edit the little table. What should change? Should I now be able to tab around the little table, whereas I couldn't before? And if so, how do I indicate that I have stopped editing the little table? Pressing Enter indicates to the little table's cell editor that its editing is finished, but how should I tell the big table's cell editor that its editing is finished?
    Perhaps if you can answer this, you may have a better idea of how to solve your problem. Sorry I only have questions and not answers.

  • Cell Editor for a JTable within A JTable Cell

    My individual cells each contain a seperate JTable and I need to write a cell editor for it. I'm not really sure how to write one so if someone show me where I can find some useful examples of such a cell editor I would greatly appreciate it. Thank you for your time. :-)

    So, you have a big table whose cells each contain a little table. I assume you already have the little tables working correctly with cell editors and so on, and you want to write a cell editor for the big table. Correct?
    My problem with this is that I can't imagine how this would actually work in practice. Suppose I click on a cell in the big table; then the cell renderer displays the appropriate little table. At this point should I see one of the cells in that little table selected, and should I be able to use the Tab key to move around the little table? And if so, then I can't use the Tab key to move around the big table. Next, suppose I press F2 indicating that I want to edit the little table. What should change? Should I now be able to tab around the little table, whereas I couldn't before? And if so, how do I indicate that I have stopped editing the little table? Pressing Enter indicates to the little table's cell editor that its editing is finished, but how should I tell the big table's cell editor that its editing is finished?
    Perhaps if you can answer this, you may have a better idea of how to solve your problem. Sorry I only have questions and not answers.

  • Dynamic Cell variant assignment

    Hi
    I wish to dynamically assign a table variant with a cell editor of type checkbox and then check/uncheck/make readonly the field accordign various situations. I only wish this to happen on certain rows.
    So far I can achieve this my using context attributes and binding to these. My only concern is that there are a lot of extra attributes required as thses cell variants appear on 7 columns and then 8 tabs.
    I would prefer to achive this solution by using the view->get_element approach, but so far I have only managed to assign the cell variant to the entire column and not an individual cell.
    Any ideas?
    Cheers
    Ian
    Edited by: Ian Stubbings on Mar 10, 2008 8:52 AM

    Hi,
    In case of a checkbox, based on the value of the attribute bound to the checkbox column, the checkbox will be checked/unchecked. Anyways, you have to have a context node of cardinality 0...n, with an attribute which can be bound to the checkbox. As far as readonly property is concerned, you can have an additional attribute in the same context node, and bind that to the read-only property of the checkbox. Alternatively, I think you can use the SET_ATTRIBUTE_PROPERTY of the IF_WD_CONTEXT_ELEMENT class.
    Hope this helps.
    Regards
    Wenonah

  • Dynamically change the cell editor in the table control

    Hi..
         I have 3 columns in a table . of which in one column we need to change the cell editor dynamically at runtime.
    i.e for example i have  columns as carrid, connid and fldate.
    For the first 2 rows the cell editor for the carrid  clomn shud be a dropdown and from there on in the next rows for the same  carrid column it shud be a input field.
    Can experts plz help me how to achieve this as this is very high priority issue....
    Regards,
    Madhu...

    This is actaully fairly simple to do.  You will need to add a cellVariant to your table column. You can then dataBind a context attribute to the selectedCellVariant property of the column to control which cellVariant will be used. This allows you to control row-by-row which cell editor you want to output.
    http://help.sap.com/saphelp_nw70/helpdata/EN/bd/5d9041d3c72e7be10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/EN/56/5e9041d3c72e7be10000000a1550b0/frameset.htm
    Also here is an example that I did the other day that uses Cell Variants within ALV.  This process is actually a little more complicated because you have to go through the ALV APIs.  To do this in a normal table is actually easier because you can create the cellVariant in the layout designer.
    Re: Freely-programmed value help for a single ALV cell

  • Dynamic Table UI Element with different data type for each cell

    Hi Experts,
    I have a problem with a dynamic Table UI Element in Web Dynpro ABAP. I have the following coding:
    METHOD set_col_row .
      TYPE-POOLS: icon.
      DATA:
        lv_node         TYPE REF TO if_wd_context_node,
        lv_node_info    TYPE REF TO if_wd_context_node_info,
        lv_element      TYPE REF TO if_wd_context_element,
        lt_attributes   TYPE wdr_context_attr_info_map,
        lv_table        TYPE REF TO cl_wd_table,
        lv_table_column TYPE REF TO cl_wd_table_column,
        lv_text_view    TYPE REF TO cl_wd_text_view,
        lv_image TYPE REF TO cl_wd_image,
        lv_text_edit TYPE REF TO cl_wd_text_edit,
        lv_header       TYPE REF TO cl_wd_caption,
        attribute       LIKE LINE OF lt_attributes,
        lv_index       TYPE string,
        lv_cur_row         TYPE i,
        path            TYPE string,
        lv_value           TYPE string,
        attr_name       TYPE string,
        l_trc_point_id  TYPE string,
        l_num_cols      TYPE string,
        l_num_rows      TYPE string,
        lv_text         TYPE string,
        lv_index2 TYPE i,
        lr_ress_selections TYPE REF TO /its/di_2_cpr_ress_selections,
        lt_comp_tab TYPE cl_abap_structdescr=>component_table,
        ls_comp_tab LIKE LINE OF lt_comp_tab,
        lv_count TYPE i,
        lv_col_count TYPE i,
        lv_col_count_read TYPE i,
        lv_index_read TYPE i,
        lv_num_cols_minus_1 TYPE i,
        lv_bind_lv_value TYPE string,
        wd_standard_cell TYPE REF TO cl_wd_table_standard_cell,
        lv_data_count TYPE i,
        lv_data_count_str TYPE string,
        wd_table_column TYPE REF TO cl_wd_table_column,
        lv_column_id TYPE string.
      FIELD-SYMBOLS:
         TYPE ANY.
    Instanz der Klasse /ITS/DI_2_CPR_RESS_SELECTIONS
      lr_ress_selections = /its/di_2_cpr_ress_selections=>factory( ).
      ASSIGN lr_ress_selections->gr_table->* TO gt_comp_tab.
      ls_comp_tab-name = 'SUMME'.
    APPEND ls_comp_tab TO lt_comp_tab.
    ls_comp_tab-name = 'CELL_VARIANT'.
      APPEND ls_comp_tab TO lt_comp_tab.
      CLEAR ls_comp_tab.
      l_num_rows = num_rows + 1.
      CONDENSE l_num_rows.
      l_num_cols = num_columns + 1.
      CONDENSE l_num_cols.
    UI-Element 'TABLE'
      lv_table ?= wd_this->m_view->get_element( 'TBL_TABLE' ).
      lv_table->remove_all_columns( ).
    Kontext-Knoten 'TABLE'
      lv_node = wd_context->get_child_node( 'TABLE' ).
      lv_node_info = lv_node->get_node_info( ).
      lv_node_info->remove_dynamic_attributes( ).
      attribute-type_name = 'STRING'.
      lv_num_cols_minus_1 = num_columns - 1.
    Für jede Spalte einmal tun
      DO lv_num_cols_minus_1 TIMES.
        lv_index = sy-index + 1.
        CONDENSE lv_index.
        lv_table_column = cl_wd_table_column=>new_table_column( ).
        lv_column_id = lv_table_column->id.
    Spaltenüberschriften setzen
        IF lv_index EQ 1. "Beim ersten Durchlauf --> erste Spalte = "Ressourcen"
          lv_text = text-010.
          sy-index = 0.
        ELSE. "Danach für jede weitere Spalte eine Zeile aus der gt_comp_tab nehmen
          lv_index_read = lv_index - 1.
          READ TABLE lt_comp_tab INDEX lv_index_read INTO ls_comp_tab.
          lv_text = ls_comp_tab-name.
          lv_header = cl_wd_caption=>new_caption( text = lv_text ).
          lv_table_column->set_header( lv_header ).
        ENDIF.
        CONCATENATE 'TABLE.A' lv_index INTO path.
        lv_text_view = cl_wd_text_view=>new_text_view( bind_text = path ).
        lv_table_column->set_table_cell_editor( lv_text_view ).
        lv_table_column->bind_selected_cell_variant( 'TABLE.CELL_VARIANT' ).
        lv_table->add_column( lv_table_column ).
        wd_table_column ?= wd_this->m_view->get_element( lv_column_id ).
    *****************Test Cell Variant*************************************************
        IF lv_index GT 1.
          LOOP AT .
              IF sy-tabix EQ lv_cur_row.
              Name zuweisen
                ASSIGN COMPONENT 'NAME' OF STRUCTURE .
              Zuweisen ob Blatt oder nicht
                lv_element->set_attribute( name = 'NAME' value = lv_value ).
                ASSIGN COMPONENT 'IS_LEAF' OF STRUCTURE set_attribute( name = attr_name value = lv_value ).
              ENDIF.
        ENDLOOP.
    Now my problem is, that I need for every ROW of my table UI Element a different cell editor. I know how to change it for the column. But is not my issue. I want to have images (traffic lights red and green) in some rows. The other rows should have numbers. The coding works, so that I have all the data at the right place in my table, only the images are shown as a string, because the cells of these rows have the cell editor Text_View. I tried something with cell variants (with cl_wd_table_standard_cell), but it was not possible for me to get a cell variant "image" in these cells/rows were I need it. 
    I hope you understand my problem and now what to do here.
    Thanks a lot in advance.
    Best Regards,
    Ingmar

    Hi Experts, I have a problem with a dynamic Table UI Element in Web Dynpro ABAP. I have the following coding: METHOD set_col_row . TYPE-POOLS: icon. DATA: lv_node TYPE REF TO if_wd_context_node, lv_node_info TYPE REF TO if_wd_context_node_info, lv_element TYPE REF TO if_wd_context_element, lt_attributes TYPE wdr_context_attr_info_map, lv_table TYPE REF TO cl_wd_table, lv_table_column TYPE REF TO cl_wd_table_column, lv_text_view TYPE REF TO cl_wd_text_view, lv_image TYPE REF TO cl_wd_image, lv_text_edit TYPE REF TO cl_wd_text_edit, lv_header TYPE REF TO cl_wd_caption, attribute LIKE LINE OF lt_attributes, lv_index TYPE string, lv_cur_row TYPE i, path TYPE string, lv_value TYPE string, attr_name TYPE string, l_trc_point_id TYPE string, l_num_cols TYPE string, l_num_rows TYPE string, lv_text TYPE string, lv_index2 TYPE i, lr_ress_selections TYPE REF TO /its/di_2_cpr_ress_selections, lt_comp_tab TYPE cl_abap_structdescr=>component_table, ls_comp_tab LIKE LINE OF lt_comp_tab, lv_count TYPE i, lv_col_count TYPE i, lv_col_count_read TYPE i, lv_index_read TYPE i, lv_num_cols_minus_1 TYPE i, lv_bind_lv_value TYPE string, wd_standard_cell TYPE REF TO cl_wd_table_standard_cell, lv_data_count TYPE i, lv_data_count_str TYPE string, wd_table_column TYPE REF TO cl_wd_table_column, lv_column_id TYPE string. FIELD-SYMBOLS:  LIKE LINE OF lt_attributes,  TYPE ANY TABLE,  TYPE ANY,  TYPE ANY,  TYPE ANY. * Instanz der Klasse /ITS/DI_2_CPR_RESS_SELECTIONS lr_ress_selections = /its/di_2_cpr_ress_selections=>factory( ). ASSIGN lr_ress_selections->gr_table->* TO . lt_comp_tab = lr_ress_selections->gt_comp_tab. ls_comp_tab-name = 'SUMME'. * APPEND ls_comp_tab TO lt_comp_tab. * ls_comp_tab-name = 'CELL_VARIANT'. APPEND ls_comp_tab TO lt_comp_tab. CLEAR ls_comp_tab. l_num_rows = num_rows + 1. CONDENSE l_num_rows. l_num_cols = num_columns + 1. CONDENSE l_num_cols. * UI-Element 'TABLE' lv_table ?= wd_this->m_view->get_element( 'TBL_TABLE' ). lv_table->remove_all_columns( ). * Kontext-Knoten 'TABLE' lv_node = wd_context->get_child_node( 'TABLE' ). lv_node_info = lv_node->get_node_info( ). lv_node_info->remove_dynamic_attributes( ). attribute-type_name = 'STRING'. lv_num_cols_minus_1 = num_columns - 1. * Für jede Spalte einmal tun DO lv_num_cols_minus_1 TIMES. lv_index = sy-index + 1. CONDENSE lv_index. lv_table_column = cl_wd_table_column=>new_table_column( ). lv_column_id = lv_table_column->id. * Spaltenüberschriften setzen IF lv_index EQ 1. "Beim ersten Durchlauf --> erste Spalte = "Ressourcen" lv_text = text-010. sy-index = 0. ELSE. "Danach für jede weitere Spalte eine Zeile aus der gt_comp_tab nehmen lv_index_read = lv_index - 1. READ TABLE lt_comp_tab INDEX lv_index_read INTO ls_comp_tab. lv_text = ls_comp_tab-name. lv_header = cl_wd_caption=>new_caption( text = lv_text ). lv_table_column->set_header( lv_header ). ENDIF. CONCATENATE 'TABLE.A' lv_index INTO path. lv_text_view = cl_wd_text_view=>new_text_view( bind_text = path ). lv_table_column->set_table_cell_editor( lv_text_view ). lv_table_column->bind_selected_cell_variant( 'TABLE.CELL_VARIANT' ). lv_table->add_column( lv_table_column ). wd_table_column ?= wd_this->m_view->get_element( lv_column_id ). ******************Test Cell Variant************************************************** IF lv_index GT 1. LOOP AT  ASSIGNING . ASSIGN COMPONENT 'TYPE' OF STRUCTURE  TO . ADD 1 TO lv_data_count. lv_data_count_str = lv_data_count. CONCATENATE 'A' lv_index lv_data_count_str INTO path. wd_standard_cell = cl_wd_table_standard_cell=>new_table_standard_cell( view = wd_this->m_view variant_key = 'FLDATE' ). IF  = '01' OR  = '04'. lv_image = cl_wd_image=>new_image( bind_source = path view = wd_this->m_view ). wd_standard_cell->set_editor( lv_image ). wd_standard_cell->set_cell_design( '01' ). ELSE. lv_text_view = cl_wd_text_view=>new_text_view( bind_text = path view = wd_this->m_view ). wd_standard_cell->set_editor( lv_text_view ). wd_standard_cell->set_cell_design( '02' ). ENDIF. wd_table_column->add_cell_variant( wd_standard_cell ). ENDLOOP. ENDIF. ************************************************************************************* CONCATENATE 'A' lv_index INTO attribute-name. lv_node_info->add_attribute( attribute ). ENDDO. DO num_rows TIMES." Für jede Zeile einmal tun lv_cur_row = sy-index. lv_element = lv_node->create_element( ). lv_node->bind_element( new_item = lv_element set_initial_elements = abap_false ). DO l_num_cols TIMES. ADD 1 TO lv_col_count. IF lv_count LT 1. LOOP AT  ASSIGNING . IF sy-tabix EQ lv_cur_row. * Name zuweisen ASSIGN COMPONENT 'NAME' OF STRUCTURE  TO . "NAME lv_value = . * Zuweisen ob Blatt oder nicht lv_element->set_attribute( name = 'NAME' value = lv_value ). ASSIGN COMPONENT 'IS_LEAF' OF STRUCTURE  TO . "NAME lv_value = . lv_element->set_attribute( name = 'IS_LEAF' value = lv_value ). ENDIF. ENDLOOP. ENDIF. IF lv_count GT 0. lv_col_count_read = lv_col_count - 1. lv_index = sy-index. LOOP AT  ASSIGNING . IF sy-tabix EQ lv_cur_row. CLEAR ls_comp_tab. READ TABLE lt_comp_tab INDEX lv_col_count_read INTO ls_comp_tab. ASSIGN COMPONENT ls_comp_tab-name OF STRUCTURE  TO . lv_value = . CONDENSE lv_index. CONCATENATE 'A' lv_index INTO attr_name. lv_element->set_attribute( name = attr_name value = lv_value ). ENDIF. ENDLOOP. ENDIF. lv_count = lv_count + 1. ENDDO. CLEAR lv_col_count. CLEAR lv_count. ENDDO. ENDMETHOD. I definied my table in Layout Tab of the View and create here in thos method dynamicly my columns. lv_table_column = cl_wd_table_column=>new_table_column( ). . . lv_table->add_column( lv_table_column ). In  I have my data that should be shown later in my table. So I create for each row in this fieldsymbol in a loop: lv_element = lv_node->create_element( ). lv_node->bind_element( new_item = lv_element set_initial_elements = abap_false ). Later I fill every cell in my table with a different value with this loop: LOOP AT  ASSIGNING . IF sy-tabix EQ lv_cur_row. CLEAR ls_comp_tab. READ TABLE lt_comp_tab INDEX lv_col_count_read INTO ls_comp_tab. ASSIGN COMPONENT ls_comp_tab-name OF STRUCTURE  TO . lv_value = . CONDENSE lv_index. CONCATENATE 'A' lv_index INTO attr_name. lv_element->set_attribute( name = attr_name value = lv_value ). ENDIF. ENDLOOP. Now my problem is, that I need for every ROW of my table UI Element a different cell editor. I know how to change it for the column. But is not my issue. I want to have images (traffic lights red and green) in some rows. The other rows should have numbers. The coding works, so that I have all the data at the right place in my table, only the images are shown as a string, because the cells of these rows have the cell editor Text_View. I tried something with cell variants (with cl_wd_table_standard_cell), but it was not possible for me to get a cell variant "image" in these cells/rows were I need it. I hope you understand my problem and now what to do here. Thanks a lot in advance. Best Regards, Ingmar

  • Dynamic Creation of cells or change of cell behaviour of a table at runtime

    Hello all,
    Can anybody tell me how can we change the cell behaviour of a table at runtime or creating the table row with different cell properties dynamically at runtime in ABAP webdynpro.
    for ex the table at runtime can be like...
    The 1st row the 1st cell can be a check box.
    The 2nd row the 1st cell can be a input field.
    The 3rd row the 1st cell can be a radio selection field.
    Business Ex : Dynamic Attributes in BID Invitation
    Thanks in advance in clarifying the doubt.

    Hi Mani,
    You could use code similar to the following code in your WDDOMODIFY method of the view in which the table is placed.
    data wd_table_cell_editor type ref to cl_Wd_view_element.
      data wd_table_column      type ref to cl_wd_table_column.
    wd_table_cell_editor ?= view->get_element( ID ). (Or any other way to get the refernce to the table cell editor)
    wd_table_column ?= wd_table_cell_editor->get__parent( ).
    (Get a refernce to table column throught table cell editor or directly)
    Now use the set_cell_editor method of wd_table_column to set the column to check box or input or any other field of your requirement.
    Also, I suggest you to use ALV as it is simpler change the cell editor and it provides many other improved functionalities.
    Regards,
    Srini.

  • Dynamically changing dropdown options in JCombox cell editor

    Hi all,
    I have a JTable with one column with JComboBox renderer and i am using the cell editor for that column as new DefaultCellEditor(JComBoBox renderer class).
    My requirement is i want to change the dropdown options basing on another column value.
    So what i did is in the setValueAt(...) function i got the table column renderer and as send the new values in a object to the renderer and in the getTableCellRendererComponent method i am checking the row number and setting the dropdown options to the JComboxBox. This works fine and the JComboBox is showing the new dropdown options correctly but when i click on the JcomboxBox cell it is showing the old dropdown options.
    So my question is how can i change the values in the editor.
    I tried like this in my setValueAt(..) functioin in my JTable model
    ( (my custom class) ((DefaultCellEditor) table.getColumnModel.getColumn(int)).getComponent).add(NewObject)
    in the new object i am sending new dropdown values and row and column but it some how it is updating renderer but not editor. Please give me the solution
    Thanks in advance
    Sunil

    You can extend DefaultCellEditor the same way as you extend cell renderer.
    After that you can set it back to your table using table.setCellEditor() method.
    best regards
    Stas

  • How to change the colour of the table cell editor on some condition?

    Hi all,
    I have a requirment acco which i need to make the colour of the tableceleditor ias RED and font color white when the data in that is < 0.please tell me how is this possible and its urgent..
    regards
    Sharan

    If you are using release NW04 and have a TextView as table cell editor, you can do this:
    Add a calculated attribute "Color" of DDIC type "com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor" under the data source node of the table.
    Bind the "semanticColor" of the cell editor to this context attribute.
    Implement the get-method for the calc. attribute like this
    WDTextViewSemanticColor get<DataSourceNode>Color(I<DataSourceNode>Element element)
      return element.getValue() < 0 ? WDTextViewSemanticColor.NEGATIVE : WDTextViewSemanticColor.STANDARD;
    Armin

  • How to create a context menu in ALV table cell editor(Webdynpro abap )

    Hello Experts,
    I am having a problem in creating a context menu in a table cell editor in the ALV table output.I have assigned a 'lta' as the cell editor.But befor assigning the lta as cell editor I have assigned the menu to the lta.But when the view is rendered I can see the lta with the actioned assigned to it.But I cannot see the context menu.
    The code snippet below:
      "Create menu for each coloumn
      create OBJECT lo_menu_actions type CL_SALV_WD_VE_MENU EXPORTING
          id = 'MITM_ACTIONS'.
      lo_menu_actions->set_visible( value = abap_true ). 
      lo_menu_actions->set_visible_fieldname( value = 'ACTIONS' ).
      "ADd menu items
      CREATE OBJECT lo_menu_item_create type CL_SALV_WD_VE_MENU
      exporting
        id = 'MITM_CREATE_EXPRESSION'.
      lo_menu_item_create->set_visible( value = abap_true ).
      lo_menu_item_create->set_visible_fieldname( value = 'Create' ).
      "Add item 1
      lo_menu_actions->ADD_ITEM( VALUE = lo_menu_item_create ). 
      "  Set the cell editor for each column cell(link to an action)
      LOOP AT lt_node_dec_tab_cols INTO ls_node_dec_tab_cols .
        lv_column_name = ls_node_dec_tab_cols-object_name.
        lr_column = lr_column_settings->get_column( lv_column_name ).
       "Create 'lta' Ui item
        CREATE OBJECT lo_lta TYPE cl_salv_wd_uie_link_to_action.
        lo_lta->set_menu( value = lo_menu_actions ).
        lo_lta->set_text_fieldname( lv_column_name ).
        lr_column->set_cell_editor( lo_lta ).
        IF ls_node_dec_tab_cols-is_result EQ abap_true.
          lr_column->set_cell_design( value =
                      cl_wd_table_column=>e_cell_design-key_medium ).
        ENDIF.
      ENDLOOP.

    Hi Prakash,
    I have not come across this requirement till now to have context menu in a cell editor of alv.
    Unfortunately  the implementation of method SET_MENU of alv ui elements ( ex: cl_salv_wd_uie_text_view ) is not updating alv configurable table, instead it just stores in a global attribute as string. Hence has no effect on context menu.
    If your user is very particular about this requirement of having context menu in cell editor, you can go for a normal table. Because, normal table's cell editor has the property to set the menuID as we do it for other ui elements.
    Regards,
    Rama

  • List UIBB - Access to cell editor for a certain table line possible

    Hi,
    I am looking for a way to access the cell editor of the last table line as I want to mark it as a special - summary - line.
    I intend a similar approach like in WebDynrpo ABAP when accessing the node info and modifying the "CELL DESIGN" attribute like in the following code (copied from WD Comp WDR_TEST_TABLE, View CELL DESIGN, method FILL_CELL_DESIGNS) :
      data tab type IF_CELL_DESIGN=>Elements_Cell_Designs.
      data line type IF_CELL_DESIGN=>Element_Cell_Designs.
      data node_info type ref to if_wd_context_node_info.
      data attribute_info type wdr_context_attribute_info.
      data attr_value type WDR_CONTEXT_ATTR_VALUE.
      node_info = node->get_node_info( ).
      attribute_info = node_info->get_attribute( 'CELL_DESIGN' ).
      line-is_expanded = abap_true.
      line-is_leaf     = abap_false.
      line-key         = 'FIRST'.
      loop at attribute_info-value_set into attr_value.
        line-text = sy-tabix.
        concatenate 'Text #' line-text into line-text. "#EC NOTEXT
        line-cell_design = attr_value-value.
        insert line into table tab.
        line-is_leaf = abap_true.
        line-key = attr_value-value.
        line-parent_key = 'FIRST'.
      endloop.
      node->bind_table( tab ).
    I suspect the method IF_FPM_GUIBB_LISTGET_DATA (or IF_FPM_GUIBB_LISTGET_DEFINITION) of my feeder class to be the right access point.
    But unfortunately, I have not yet found out how to change the cell design for specific lines, only for whole columns.
    Can anyone give me a hint here?
    BTW: The "summary" line is not a sum of the lines above, but determined by backend logic, so not ALV-summary line for me.
    Kind Regards

    Hi,
    A short update for all interested:
    My current work around is to always set the lead selection to the summary line. It does in a kind "mark" that line as special as long as I cannot mark it using a different cell design.
    How do I assure this?
    I have implemented the following code in a redefinition of the method ADJUST_SELECTION:
    *- alter selection
      DATA:
       ls_size TYPE rstabix.
      "get index of summary line
      ls_size-tabix = mo_collection->size( ).
      "change only if there are any cash conc. proposals
      IF ls_size-tabix > 0.
        "do FPM selection
        CLEAR: ev_lead_index, et_selection.
        ev_lead_index = ls_size-tabix.
        APPEND ls_size TO et_selection.
        "do BOL selection
        mo_collection->if_bol_bo_col_multi_sel~unmark_all( ).
        mo_collection->if_bol_bo_col_multi_sel~mark( iv_index = ls_size-tabix ).
      ENDIF.
    The general downside is, that no other selection is possible!
    The selection is always reset to the summary line with each roundtrip.
    Waiting for a better solution...
    Kind Regards,
    Robert

  • How to change the name of an XML data element in link editor?

    Hi,
    Is it possible to change the name of a data element dynamically while doing the assignment in the link editor?
    Something like Transaction.ReceiveXML{/Rowsets/Row/Name1 (name="Name2")}?
    Regards,
    V M.

    Hi VM,
    in the link editor you can use the Dynamic Link (see [Expression Editor|http://help.sap.com/saphelp_mii121/helpdata/EN/45/b89adfaf1447f7e10000000a114a6b/frameset.htm]).
    With the dynamic link, you can enclose the property that contains the value with "#", which makes MII evaluate the value rather than use the property name. In your example, it looks something like this:
    ReceiveXML{/Rowsets/Row[name='#MyProperty#']}
    Hope this helps.
    Michael
    Edited by: Michael Otto on Oct 27, 2010 8:09 AM

  • Small issue with custom table cell editor and unwanted table row selection

    I'm using a custom table cell editor to display a JTree. Thing i notice is that when i select a value in the tree pop-up, the pop-up closes (as it should) but then every table row, from the editing row to the row behind the pop-up when i selected the value becomes highlighted. I'm thinking this is a focus issue, but it thought i took care of that. To clairfy, look at this: Before . Notice how the "Straightening" tree item is roughly above the "Stock Thickness" table row? When i select Straightening, this is what happens to my table: After .
    My TreeComboBox component:
    public class TreeComboBox extends JPanel implements MouseListener {
        private JTextField itemField;
        private TreeModel treeModel;
        private ArrayList<ActionListener> actionListeners = new ArrayList<ActionListener>();
        private Object selectedItem;
         * Creates a new <code>TreeComboBox</code> instance.
         * @param treeModel the tree model to be used in the drop-down selector.
        public TreeComboBox(TreeModel treeModel) {
            this(treeModel, null);
         * Creates a new <code>TreeComboBox</code> instance.
         * @param treeModel the tree model to be used in the drop-down selector.
         * @param selectedItem tree will expand and highlight this item.
        public TreeComboBox(TreeModel treeModel, Object selectedItem) {
            this.treeModel = treeModel;
            this.selectedItem = selectedItem;
            initComponents();
         * Returns the current drop-down tree model.
         * @return the current <code>TreeModel</code> instance.
        public TreeModel getTreeModel() {
            return treeModel;
         * Sets the tree model.
         * @param treeModel a <code>TreeModel</code> instance.
        public void setTreeModel(TreeModel treeModel) {
            this.treeModel = treeModel;
         * Returns the selected item from the drop-down selector.
         * @return the selected tree object.
        public Object getSelectedItem() {
            return selectedItem;
         * Sets the selected item in the drop-down selector.
         * @param selectedItem tree will expand and highlight this item.
        public void setSelectedItem(Object selectedItem) {
            this.selectedItem = selectedItem;
            String text = selectedItem != null ? selectedItem.toString() : "";
            itemField.setText(text);
            setToolTipText(text);
         * Overridden to enable/disable all child components.
         * @param enabled flat to enable or disable this component.
        public void setEnabled(boolean enabled) {
            itemField.setEnabled(enabled);
            super.setEnabled(enabled);
        public void addActionListener(ActionListener listener) {
            actionListeners.add(listener);
        public void removeActionListener(ActionListener listener) {
            actionListeners.remove(listener);
        // MouseListener implementation
        public void mouseClicked(MouseEvent e) {
        public void mouseEntered(MouseEvent e) {
        public void mouseExited(MouseEvent e) {
        public void mousePressed(MouseEvent e) {
        public void mouseReleased(MouseEvent e) {
            showPopup();
        private void initComponents() {
            setLayout(new GridBagLayout());
            itemField = new JTextField();
            itemField.setEditable(false);
            itemField.setText(selectedItem != null ? selectedItem.toString() : "");
            itemField.addMouseListener(this);
            add(itemField, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
                    GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
        private void showPopup() {
            final TreePopup popup = new TreePopup();
            final TreeComboBox tcb = this;
            final int x = itemField.getX();
            final int y = itemField.getY() + itemField.getHeight();
            int width = itemField.getWidth() + popupButton.getWidth();
            Dimension prefSize = popup.getPreferredSize();
            prefSize.width = width;
            popup.setPreferredSize(prefSize);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    popup.show(tcb, x, y);
                    popup.requestFocusInWindow();
        private void fireActionPerformed() {
            ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "TreeComboBoxSelection");
            for (ActionListener listener : actionListeners) {
                listener.actionPerformed(e);
        private class TreePopup extends JPopupMenu {
            private JTree tree;
            private JScrollPane scrollPane;
            public TreePopup() {
                initComponents();
                initData();
            private void initData() {
                if (treeModel != null) {
                    tree.setModel(treeModel);
            private void initComponents() {
                setFocusable(true);
                setFocusCycleRoot(true);
                tree = new JTree();
                tree.setRootVisible(false);
                tree.setShowsRootHandles(true);
                tree.setFocusable(true);
                tree.setFocusCycleRoot(true);
                tree.addTreeSelectionListener(new TreeSelectionListener() {
                    public void valueChanged(TreeSelectionEvent e) {
                        tree_valueChanged(e);
                scrollPane = new JScrollPane(tree);
                add(scrollPane);
            private void tree_valueChanged(TreeSelectionEvent e) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
                setSelectedItem(node.getUserObject());
                fireActionPerformed();
                this.setVisible(false);
    }My TreeComboBoxTableCellEditor:
    public class TreeComboBoxTableCellEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {
        protected TreeComboBox treeComboBox;
        protected ArrayList<CellEditorListener> cellEditorListeners = new ArrayList<CellEditorListener>();
        public TreeComboBoxTableCellEditor(TreeComboBox treeComboBox) {
            this.treeComboBox = treeComboBox;
            treeComboBox.addActionListener(this);
        public Object getCellEditorValue() {
            return treeComboBox.getSelectedItem();
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
            treeComboBox.setSelectedItem(value);
            return treeComboBox;
        public void actionPerformed(ActionEvent e) {
            stopCellEditing();
    }Any thoughts?
    Edited by: MiseryMachine on Apr 3, 2008 1:21 PM
    Edited by: MiseryMachine on Apr 3, 2008 1:27 PM

    As I said, you have to have empty context elements before additional rows will be open for input.
    For instance if you want to start with 5 rows available for input do the following to your internal table that you will bind:
    data itab type standard table of sflight.
    do 5 times.
      append initial line to itab.
    enddo.
    context_node->bind_table( itab ).
    The other option if you need n number of rows is to add a button to the table toolbar for adding more rows. When this button is pressed, you add a new context element to the node - thereby creating a new empty row in the table.

  • How to add cell editor to cell variant dynamically?

    Hi everyone,
      I'm developing a web dynrpo component. In one of the views , I need to modify the view dynamically
    because the data structure only can be determined at runtime. And the table column should have two
    cell variants. I don't know the exact cell variant class which should be used. I only find an abstract class about cell variant CL_WD_ABSTR_TABLE_CELL_VAR , but I can't find any method in this class which
    can add cell editor under this cell variant.
    Thanks in advance.

    Hi Sireesha,
    Thanks for link you provided.
    I am able to add Column with CommandImageLink.And onclick of that link i am able to display another popup.
    Now another problem which i am facing is when i select one row from popup and click "Ok" i have to modify some columns from Dyanamic table which is displayed on main page.
    For this.
    1)First i took the selected row from dyanamic table to update that perticular row depending upon the row which i select from popup.
    if you see the code above i am refaring the list as collection for data.So i am updating that collection but again it is refreshing to it's original value.
    because number of times getList() method of bean get's called equal to number of columns. which brings the values from database.
    Here On click of popup's Ok button I don't want to save the data for table i just want to show there in some column's .and After click on SAVE button from table i have to save it.
    Let me help how can i modify the Dynamic table's data.
    Thanks for all help.
    Jaydeep

Maybe you are looking for