cancel
Showing results for 
Search instead for 
Did you mean: 

IC WebClient: Add Dropdown Box to TableView

brad_bohn
Active Contributor
0 Kudos

Has anyone successfully added a dropdown box inside of a CRM IC WebClient table that uses a context node? If so, I would appreciate some advice! I have read Brian's blog about table view iterators, but as usual the application in CRM is slightly different.

I'm working with a custom column in the result list (Customers context) on the BuPaSelectCustomer view. I want my custom column to be editable via a dropdown box. Here's what I've done:

1) Created a custom class that implements the IF_HTMLB_TABLEVIEW_ITERATOR interface

2) Created an attribute of the Customers context class called ITERATOR that is typed as the new class in #1

3) Added the iterator attribute to the crmic:tableView

element in the page which points to the attribute defined in #2: iterator = "<%= customers->iterator %>"

4) Set edit = "TRUE" attribute in the crmic:tableViewColumn element for my new column named 'ZZSLSTATUS'

5) In the controller class SET_MODELS method:


* Create iterator for table
  IF NOT iterator IS BOUND.
    CREATE OBJECT iterator TYPE ZCL_CRM_SELCUST_TV_ITERATOR
      EXPORTING
        ir_context_node = typed_context->customers.
  ENDIF.

The constructor looks like this:


method CONSTRUCTOR .
  gr_context_node = ir_context_node.
endmethod.

6) GET_COLUMN_DEFINITIONS looks like this:


  data: wrapper type ref to cl_bsp_wd_collection_wrapper.

  gv_current_line = 0.
  gv_tableview_id = p_tableview_id.

* get the wrapper of the context node
  wrapper = gr_context_node->get_collection_wrapper( ).

* fill the local iterator
  gr_iterator = wrapper->get_iterator( ).

7) RENDER_ROW_START looks like this:


* Position on correct index
  gr_iterator->get_by_index( iv_index = p_row_index ).

😎 RENDER_CELL_START looks like this:


DATA: LT_RECSTAT      TYPE TABLE OF IHTTPNVP,
      LS_RECSTAT      TYPE IHTTPNVP,
      LR_COL_DROPDOWN TYPE REF TO CL_HTMLB_DROPDOWNLISTBOX.

FIELD-SYMBOLS: <TABLE> TYPE  TIHTTPNVP.

* Simple 1 record table for now
  LS_RECSTAT-NAME  = '1'.
  LS_RECSTAT-VALUE = 'Not Called'.

  APPEND LS_RECSTAT TO LT_RECSTAT.

  CASE P_COLUMN_KEY.

    WHEN 'ZZSLSTATUS'.

      IF NOT P_EDIT_MODE IS INITIAL.

*       Create replacement bee to show a dropdown listbox in the
*       table cell
        CREATE OBJECT LR_COL_DROPDOWN.
        LR_COL_DROPDOWN->ID                = P_CELL_ID.
        LR_COL_DROPDOWN->NAMEOFKEYCOLUMN   = 'NAME'.
        LR_COL_DROPDOWN->NAMEOFVALUECOLUMN = 'VALUE'.

        TRY.
            CREATE DATA LR_COL_DROPDOWN->TABLE TYPE TIHTTPNVP.
          CATCH CX_SY_CREATE_DATA_ERROR.
            RETURN.
        ENDTRY.

        ASSIGN LR_COL_DROPDOWN->TABLE->* TO <TABLE>.
        IF SY-SUBRC = 0.
          <TABLE> = LT_RECSTAT.
        ENDIF.

        LR_COL_DROPDOWN->SELECTION = GR_CONTEXT_NODE->GET_ZZSLSTATUS(
                                            ATTRIBUTE_PATH = ''
                                            ITERATOR = GR_ITERATOR ).

        P_REPLACEMENT_BEE = LR_COL_DROPDOWN.

      ENDIF.

  ENDCASE.

Nothing happens to the cells in my column (they still appear as uneditable with their initial values) and my breakpoints aren't hit in the custom iterator class methods when the table is rendered. Any ideas?

Thanks,

Brad

View Entire Topic
0 Kudos

Hi Brad,

I had only a very fast read through your question but based on the fact that your breakpoints do not get raised -i.e. your class is not being called I think you are instantiating the wrong reference. You could try

create object typed_context->customers->iterator

exporting

ir_context_node = typed_context->customers.

This way the attribute of the context referenced for the tableview tag is instantiated. From your code I could not determine where iterator reference in set_models comes from.

Cheers, Jared

brad_bohn
Active Contributor
0 Kudos

Nice catch (based on a fast read through). That did allow me to actually hit breakpoints in the methods, but it still did not solve the issue. I'll have to do some more debugging now. Thanks for the help.

brad_bohn
Active Contributor
0 Kudos

Got it! For some reason (I haven't debugged that far yet), even though edit="TRUE" on that column, the value of P_EDIT_MODE was blank for that column in the RENDER_CELL_START method. I commented out the IF condition, added a few more lines to my local table (based on a domain value set now instead of hard-coding) and the dropdown showed up with the correct values for each row.

Former Member
0 Kudos

Congrats Brad, please make sure to mark the question as resolved. The reason for mentioning it makes it easier for readers to find actual solutions in this forum. Cheers, Tiest.