cancel
Showing results for 
Search instead for 
Did you mean: 

How to dinamically disable an entire row in a table

matteo_montalto
Contributor
0 Kudos

Hi all gurus,

here's my requirement: under certain conditions, one or more rows in a custom table of a custom WD should be disabled (e.g., every field is visible but not editable, just read-only).

The table, just to simplify the example, is made up of 4 custom fields (z1, z2, z3, z4). I know I could add a new custom field, say z_enabled, and bind it to the enabled property for the table rows... Anyway, I was looking for another dynamic approach; could you gurus give me an help on this?

Here's the sketch of code I wrote:

lo_nd_zr7_wds_fplt = wd_context->get_child_node( name = wd_this->wdctx_zr7_wds_fplt ). "my table node
  CALL METHOD lo_nd_zr7_wds_fplt->get_elements
*    EXPORTING
*      from   =
*      to     =
    receiving
      set    = lt_element_rows
      .
LOOP AT lt_element_rows INTO lt_row.
IF "some conditions are meet...
* disable entirely the row
* calling the get() method for debugging purpose... and reusing props structure
    CALL METHOD lt_row->get_attribute_props_for_elem
      receiving
        properties = props
* 1
......
* after props have been set properly, call the set() method
    CALL METHOD lt_row->set_attribute_props_for_elem
      EXPORTING
        properties  = props
*        keep_others = ABAP_FALSE
        .
    ENDIF.
  ENDLOOP.

Here's the clue; when I use the GET() method I expect to receive the "runtime" property for the row... unfortunately, the table props returned is empty.

I tried then to populate the table in debug, in the following way, for each field's table:

ATTRIBUTE_NAME = field name (z1, z2 , etc... the prop table will finally have 4 entries)

REQUIRED = blank.

READ_ONLY = 'X'

VISIBLE = 'X'

ENABLED = blank.

assuming that disabling every field of the row (element) is equivalent to row's disabling. But nothing changes.

Could anyone please suggest me further hints/suggestions to solve the task? Am I missing something?

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Crete one attribute of type WDUI_VISIBILITY say VISIBLE and bind this to visibile property of table columns.

Based on your condtion... Set to invisible that column.

IF < Condtion >

lo_el_context->set_attribute(
name = `VISIBLE`
value = '01' ). // 01 - none, 02 - visible

Endif.

Cheers,

Kris.

Cheers,

Kris.

matteo_montalto
Contributor
0 Kudos

Thanks kissnas, but unfortunately I'm dealing with rows of the table and not with columns....

Further details; I've seen in debug that every row of the table (which is a type ref to if_wd_context_element) has two attributes, named:

IF_WD_CONTEXT_ELEMENT~E_PROPERTY_DEFAULT

IF_WD_CONTEXT_ELEMENT~E_PROPERTY

The second one - which is the one I suppose I have to modify - is made up by these values:

REQUIRED

READ_ONLY

VISIBLE X

ENABLED X

and also, the last column of this table is called READ_ONLY and is set to 'X' for each property.

Given that this WD is completely custom, how can I access/modify these properties? I suppose I have first to identify why read_only is set to X... I cannot in fact change any value of IF_WD_CONTEXT_ELEMENT~E_PROPERTY in debug.

matteo_montalto
Contributor
0 Kudos

> Crete one attribute of type WDUI_VISIBILITY say VISIBLE and bind this to visibile property of table columns.

> Based on your condtion... Set to invisible that column.

>

>

IF < Condtion >
> 
> lo_el_context->set_attribute(
> name = `VISIBLE`
> value = '01' ). // 01 - none, 02 - visible
> 
> Endif.

Kris, maybe I misunderstood, anyway... I'm dealing with the ENABLED property, because I'd like to prevent some rows from being edited. Could you please help me further on this? As you stated above, I should enhance the table with a new field, say ENABLED, and bind this one to the ENABLED property of the table itself?

In particular, what's then the type of this attribute?

Thanks!

Former Member
0 Kudos

Hi

It is quite simple actually

what you need to do is add one more attribute of type wdy_boolean to every attribute you have under your node.

Accordingly:

node

attr_1

attr_1_enabled

attr_2

attr_2_enabled

etc....

in your designer bind every ui element prperty thus: text binds to attr_1, enabled binds to attr_1_enabled. (or read only)

in your code, loop thru all lines, bind the value you get from R3 to the text. if you are in the line to be disabled,

set the ui property enabled to disabled.

that's it

regards

yuval

saravanan_narayanan
Active Contributor
0 Kudos

Hello,

type the attribute should be BOOLEAN and it should be bound to the ENABLED property of all the CELL_EDITORS in all the TABLE_COLUMNs.

BR, Saravanan

Former Member
0 Kudos

Hi

Type should be WDY_BOOLEAN .. bnd this to enable property if you want to display only..

Cheers,

Kris.

Answers (1)

Answers (1)

matteo_montalto
Contributor
0 Kudos

Thanks to you all, problem solved!