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

Accepted Solutions (1)

Accepted Solutions (1)

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.

Answers (2)

Answers (2)

Former Member
0 Kudos

Brad or anyone who could help:

I found this article very useful and tried to follow the samples. I am not very experienced in BSP and I only need to add a column to BuPaSelectCPforCustomer IC webclient tableview.

Step 1 - done.

step 2 - I am not sure I did it right. I created a custom class ZCL_CRM_IC_BUPASELCP_CN02 for CONTACTRELATION and added an attribute ITERATOR to the class.

step 3 I add this to crmic:tableView

iterator = "<%= CONTACTRELATION->iterator %>"

but I go compile errors like "Field iterator is unknown".

Step 4 - skip

Step 5 - I assume the controller class is the top controller which in my case is ZL_CRM_IC_BUPASELECTCPFOR_IMPL->SET_MODELS. I added this code:

IF NOT iterator IS BOUND.

ENDIF.

I got the same compile errors like "Field iterator is unknown".

I think I missed something somewhere. I would really appreciate it if you could shed more light on this.

Thank you so much.

Former Member
0 Kudos

Brad, just an initial thought, but does your custom column have a check table assigned to it. I am wondering if you add a checktable referencing the possible drop down values your drop down list is being populated correctly, Tiest.

brad_bohn
Active Contributor
0 Kudos

Tiest, thanks for the suggestion. In RENDER_CELL_START, I have created a local table with one entry and assigned it to the replacement BEE. I think something else in the setup is missing because I can't get a breakpoint to hit in this method; the only breakpoint that gets hit in the class is in the constructor when the iterator gets created.