cancel
Showing results for 
Search instead for 
Did you mean: 

Disable Button when deselect row in a table

Former Member
0 Kudos

Hi All,

In my requirement, i have buttons in disable mode, when user select any record buttons are enabled. this is working fine, when user deselect that row i want to disable those buttons again. i tried this but not getting disable when deselect row.. can anyone help this...?

Thanks,

Venkat

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi,

I think your problem is "How to deselect the row of table"..

You can use clear selection or set_lead_selction_index(-1) by checking the deselected context element is selected already or not..

Also,you can see the post:

Hope it can help you a little.

Best wishes,

Former Member
0 Kudos

Hi Anurag and Tan

When select any row enableing is working, deselection also working. when deselect row disabling is not working, here i am using code...

IF lr_element->is_selected( ) is not initial.

  • get single attribute

lr_element->set_attribute(

EXPORTING

name = `SET_ENABLE`

value = ABAP_TRUE ).

else.

lr_element->set_attribute(

EXPORTING

name = `SET_ENABLE`

value = ABAP_FALSE ).

endif.

i set a breakpoint and checking, what i am observing is when both select and deselect a row it is executing only in if block, curson is not coming to else block... how can we slove this??

Thanks,

Venkat.

Former Member
0 Kudos

Hi Venkatesh,

you need to check if any of the row is selected or not.

u could do that at node level using get_selected_elements of if_wd_context_node.

Regards

Anurag Chopra

Former Member
0 Kudos

Please go through the post [;

hope this could help you in achieving desired result

Thanks

Vishal Kapoor

Former Member
0 Kudos

Hi Vishal,

Deselection is working, but when deselect a row i want to disable buttons. that is not working. Any help please.

Thanks,

Venkat

Former Member
0 Kudos

hi,Venkat.

From your description, your logic is very clear..I don't know how to track the problem.

You said your coding doesnot go the "Else" clause..So, only what i can see is you should check the method"r_element->is_selected( )", check how the method is executed and why it returns "No initial"..

In addition, in my opinion, you should think:

As you are now de-selecting the row, so in your mind you should know: whether your method "r_element->is_selected( )" is till use the "Non-de-selected" the element...

If it does, i think you should change.For example, you can then "get selected element" of the "Context node" to check whether the element is True de-selected...

Hope it can help a little.

Best wishes.

Former Member
0 Kudos

Hi Tang,

I again tried this, after enableing i am deselecting row using set selected. it is working fine for same row i.e. if iam selecting 2nd row buttons are enabled, if i deselect 2nd buttons are desabled, but after selecting 2nd row( buttons are enabled now) if i select any other row ex. 3rd row again disable that buttons. can u help me??

if lr_element->is_selected( ) = abap_true.

lo_el_context->set_attribute(

EXPORTING

name = `SET_ENABLE`

value = ABAP_TRUE ).

lr_element->set_selected( abap_false ).

else.

lo_el_context->set_attribute(

EXPORTING

name = `SET_ENABLE`

value = ABAP_FALSE ).

lr_element->set_selected( abap_true ).

endif.

Thanks,

venkat.

Former Member
0 Kudos

Have you tried to code in Modify View. (I am not sure abt it).

Alternatively you can make one more column in your table.

And make that column as Button.

Now OnLeadSelect method of the table, you can write logic to enable the button for the selected rows.

Hence the button will be enabled for the selected rows.

But the user has to click the button column number of times that they have selected the rows.

Regards,

S.Meganadhan

Former Member
0 Kudos

Hi Venkat,

You could declare an attribute of type wdy_boolean and bind it to enabled property of a button.

and you could pass value 'X' if a user has selected any row of a table and ' ' blank if there is no row selected.

you could use the method get_selected_elements( ) of if_wd_context_node, you would receive a table of type wdr_context_element_set. just check if the table is empty or not. if it is empty,,,that means no row is selected.

Regards

Anurag Chopra