Skip to Content
avatar image
Former Member

Posting values from a table into checkboxes in a checkboxgroup

Here is my situation.

I have a table I am reading into my web dynpro. There are five fields, each may or may not contain an 'X'.

I have a checkboxgroup in my web dynpro. What I need to do is read field one, and if it is 'X', set the first checkbox in the group to true. Then do the same with the other four fields. I am using a checkbox group because I am reading the labels for the fields from an existing table.

I am have not used a checkboxgroup so this is new to me. Can anyone provide some code examples I can use to get my head around this?

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Apr 14, 2011 at 07:20 PM

    Hi,

    See the help here. [http://help.sap.com/saphelp_nw70ehp1/helpdata/en/cd/ad884118aa1709e10000000a155106/content.htm|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/cd/ad884118aa1709e10000000a155106/content.htm]

    See the example component as described on the help page.

    Basically you need a context-node of cardinality 0..n. The number of element in the node represents number of checkboxes in the group.

    bind the enabled property based on the value X from the table column.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member
      data lo_node type if_wd_context_node.
      
      lo_node = wd_context->get_child_node( name = wd_this->wdctx_YOUR_NODE ).
      
      loop at lt_my_table into ls_my_table.
      
        if ls_my_table-check_field = 'X'.
          lo_node->set_selected( index = sy-tabix ).
        endif.
      
      endloop.
      

      or something like this. You can also reference the selected property at the if_wd_context_element level which does not require an index.