cancel
Showing results for 
Search instead for 
Did you mean: 

Select/De-Select all elements in a Checkbox Group

Former Member
0 Kudos

Hi experts,

I'm looking for solution how to check resp. uncheck all elements in a CHECKBOX_GROUP UI element.

The group is filled with a select over a table which also contains a SELECTED flag.

Now I want to provide 2 buttons on my WD to select or unselect all elements in this group. But unfortunately I haven't found a solution yet.

I'm fine with the context values, means I can change the mentioned SELECTED flag as wished, but I can't manage it that the checkboxes on the UI are updated correctly.

Any ideas?

Regards, Steffen

Edited by: Steffen Weber on Oct 6, 2008 4:01 PM

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>I'm fine with the context values, means I can change the mentioned SELECTED flag as wished, but I can't manage it that the checkboxes on the UI are updated correctly.

I'm not sure I understand. If designed correctly, the UI bound to the context will update automatically. So either you have the binding wrong or you aren't actually getting the context values updated as you think.

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

in the CheckBoxGroup UI element I'm only able to bind the "texts", which gets all the checkbox descriptions out of the context. But for the checkbox itself I can't find a property which could be bound to the context.

So there seems to be 2 properties:

- the checkbox text and

- the checkbox itself

which need to be bound.

But I can only find the one for texts, or am I doing something wrong?

Regards, Steffen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

No you have done the binding correctly, you just don't realize it. You only need to bind to the text attribute. There is no attribute for selection. The UI element uses the selection of the context node element itself to determine the state of the UI element.

Try reading the online help for data binding of the checkbox group:

A CheckBoxGroup is a multiple selection displayed as a group of checkboxes on the screen.

The view context must provide the node X that can contain 0 to n values (cardinality=0..n). The context node must contain an attribute y that provides the texts for the checkbox fields. The data type of the context attribute y can be any simple data type u2013 for example, String, int, and so on. The number of checkboxes equals the number of node elements. The selection of the checkboxes is determined by the multiple selection of the node. The texts property of the CheckBoxGroup UI element is bound to the attribute y by assigning the context path of the context y to the texts property.

Therefore you would set the selection or remove the selection for a particular checkbox with the method SET_SELECTION of the IF_WD_CONTEXT_ELEMENT object.

steffen_weber
Employee
Employee
0 Kudos

Hi Thomas,

yes, this is the answer. I have read this article this morning but somehow I missed the note with the cardinality of the selection. With 0..n cardinality and the following code to set the selection it works properly:

lv_idx = 1.
DO n TIMES.
     lo_el_mail_recipients = lo_nd_mail_recipients->get_element( index = lv_idx ).
     lo_el_mail_recipients->set_selected( abap_true ).
     lv_idx = lv_idx +1.
ENDDO.

But, the method seems to be SET_SELECTED and not as you mentioned SET_SELECTION

Thanks a lot for your support!

Steffen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

>

> But, the method seems to be SET_SELECTED and not as you mentioned SET_SELECTION

>

> Thanks a lot for your support!

> Steffen

You are correct. I even still had the code sample pulled up on my desktop. I just mistyped the method name in my response. Hope it didn't send you down an incorrect path.

steffen_weber
Employee
Employee
0 Kudos

No worries!

Before I started to use the code, I had a look at the Interface Description and there I found the correct spelling.

Have a nice day, und bis zur nächsten Frage

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Steffen,

Create 2 button one for Select and another for deselect.

On pressing select/Deselect button (button event), assign corresponding boolean value to check box attributes. Hope this will work.

Regards,

Karthick S

steffen_weber
Employee
Employee
0 Kudos

Hi,

do I really need to implement this?

I thought it will be sufficient to set the context attributes.

But as I mentioned, there seems to no property in a CheckBoxGroup which represents the single CheckBox values/states, just the texts.

If i need to implement this, maybe you have an example available?

Regards, Steffen