cancel
Showing results for 
Search instead for 
Did you mean: 

Reg : Selecting a row in table

Former Member
0 Kudos

HI,

I have a table(not ALV) which displays records . I have a column by name STATUS .

THE STATUS clomn contains either 'X' or space...null value .

By using the chekcbox...the user is selecting the rows.

now my question is :

if the table has 4 records....out of which two rows have 'X' in the status column and two rows have null value.

the checkbox for selecting the rows should be ENABLED For the rows which have X in the status colomn..

the checkbox for selecting the rows should be DISABLED for the rows which have 'null value or space ' in the status colomn..

clo1 status

aa X----


>>>the check box for for selecting the rows should be ENABLED

bb X----


>>>the check box for for selecting the rows should be ENABLED

cc -


>>>the check box for for selecting the rows should be DISABLED

dd -


>>>the check box for for selecting the rows should be DISABLED

ANY HELP PLZ??

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Arjun,

If you meant to enable/disable the button that appears at the beginning of each table's row for selecting a row then you can proceed as follows:

Bind the rowSelectable property of the Table to the FLAG attribute. If you do this binding and use the same coding which I had given you earlier then you would end up with only rows which have PRICE > 500 as selectable by the user.

Regards,

Uday

Answers (4)

Answers (4)

uday_gubbala2
Active Contributor
0 Kudos

Below is the coding from my supply function:

method SUPPLY_DATA .
  data: wa_sflight type wd_this->element_sflight,
        lt_sflight type wd_this->elements_sflight.
  select carrid
         connid
         fldate
         price from sflight into corresponding fields of table lt_sflight.
  sort lt_sflight by price.
  delete adjacent duplicates from lt_sflight comparing price.

  loop at lt_sflight into wa_sflight.
    if wa_sflight-price > 500.
      wa_sflight-flag = 'X'.
      modify lt_sflight from wa_sflight transporting flag.
    endif.
  endloop.

  node->bind_table( new_items = lt_sflight ).
endmethod.

uday_gubbala2
Active Contributor
0 Kudos

Hi Arjun,

Did you mean to say that you wanted the checkbox within your table to be conditionally enabled/disabled? If yes then below is the code for a similar situation which you can use for your scenario.

Suppose am displaying the data from SFLIGHT & have a column (CHECK) with checkboxes in it. I want the checkboxes to be enabled only for the rows where PRICE > 500.

I have a context node SFLIGHT with CARRID, CONNID, FLDATE & PRICE as attributes under it. In addition to them I have 2 more ABAP_BOOL attributes CHECK & FLAG. I use the CHECK attribute to bind to the "checked" property of the checkbox in CHECK column. I use the FLAG attribute to bind to the "enabled" property of the checkbox in CHECK column. I create a supply function for my node using which I populate the table and achieve this conditional enabling/disabling of my checkbox.

Regards,

Uday

Former Member
0 Kudos

Create an attribute 'EDITABLE' type String under the same node that is bound to your table.

Bind this attribute to the read_only property of your checkbox ( celleditor ).

Now use the following code.

data: l_node type ref to if_wd_context_node.
data: itab type if_viewname=>elements_nodename.

" get the contents of the table
l_node = wd_context->get_child_node( 'NODENAME' ).
l_node->get_static_attributes_table( importing table = itab ).

loop at itab into ls_stru.
 if ls_stru-status eq 'X'.
     ls_stru-editable = abap_false.
 else.
     ls_stru-editable = abap_true.
 endif.
   
 modify itab from ls_stru transporting editable.
endloop.

" bind the table
 l_node->bind_table( itab ).

Regards,

Radhika.

Former Member
0 Kudos

Hi,

Please bind the enable property of checkbox to the context_attribute(binded to checkbox element) enabled property. Check the value of attribute STATUS and if it is null then set the enabled property of checkbox context_attribute to abap_false otherwise make it abap_true.

Intercface = if_wd_context_element

method = SET_ATTRIBUTE_PROPERTY

Thanks,

Rahul