cancel
Showing results for 
Search instead for 
Did you mean: 

Deselection of a row in table

Former Member
0 Kudos

Hi Experts,

Deselection is posible in table? in table user selecting one row after that if user click outside the table or at any place in that view or again select that selected row, that time i want to deselect the selection? is it possible ? how can we achieve this...

Thanks,

kris

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

You can achieve this feature the way we have in sap ABAP screen programming. means, if you select the row, it is selected and if you select the row selection button again, it will be deselected.

Create 2 attributes in component controller: ACTION_NAME type string and INDEX of type integer ( I )

in method WDDOBEFOREACTION, capture the action name in attribute ACTION_NAME

Now go to the method WDDOMODIFYVIEW and write the below code

method WDDOBEFOREACTION .

data lo_api_controller type ref to if_wd_view_controller.

data lo_action type ref to if_wd_action.

lo_api_controller = wd_this->wd_get_api( ).

lo_action = lo_api_controller->get_current_action( ).

if lo_action is bound.

wd_comp_controller->action_name = lo_action->name.

endif.

endmethod.

Create one action say 'LEADSELECT' and attach it with the event OnLeadSelect event of the table. No code is required in this event handler.

In WDDOMODIFYVIEW method of the view, write the below code:

METHOD wddomodifyview .

*Assume this is the node which holds the table data

DATA lo_nd_flight TYPE REF TO if_wd_context_node.

DATA lo_el_flight TYPE REF TO if_wd_context_element.

DATA ls_flight TYPE wd_this->element_flight.

DATA lv_index TYPE i.

IF wd_comp_controller->action_name = 'LEADSELECT'.

lo_nd_flight = wd_context->get_child_node( name = wd_this->wdctx_flight ).

*Get the currently selected row ( if any )

CALL METHOD lo_nd_flight->get_lead_selection_index

RECEIVING

index = lv_index.

*This condition is to ensure that if the same row is clicked again, it is unselected

IF wd_comp_controller->lv_index EQ lv_index AND wd_comp_controller->lv_index IS NOT INITIAL.

*Below methods call will make sure that lead selection is removed

CALL METHOD lo_nd_flight->clear_selection.

lo_nd_flight->set_lead_selection_index( '-1' ).

CLEAR wd_comp_controller->index.

ELSE.

wd_comp_controller->index = lv_index.

ENDIF.

ENDIF.

ENDMETHOD.

Now launch your application any just use the button in first table column to select/unselect the table row

Thanks

Vishal Kapoor

Former Member
0 Kudos

Hi Vishal..

Thanks for your reply..

i am going thropugh your code... i am getting error Action_name is unknown, but i declared that.. can u check this???

Thanks,

kriss.

Former Member
0 Kudos

Hello,

Action_name is declared in the ATTRIBUTE tab of COMPONENTCONTROLLER. it is accessed later on using attribute wd_comp_controller. have u used any other style to capture action ?

Regards

Vishal Kapoor

Edited by: vishal kapoor on Oct 19, 2010 9:54 AM

Former Member
0 Kudos

hi Vishal,

I Declared ACtion_name and Index in attributes tab of Comp Controller, still i am getting same error here...

ERROR: Field Action_name is unknown.

wd_comp_controller->action_name = lo_action->name.

Thanks,,

Kris.

Former Member
0 Kudos

Hey,

When you are defining your attribute in component controller, have you checked the checkbox under column " public" next to attribute name ? If the attribute is not poublic, it will not be available in any other method.

Thanks

Vishal kapoor

Former Member
0 Kudos

Thanks Vishal...

Thanks,

kris.

Answers (5)

Answers (5)

Former Member
0 Kudos

hi,

I believe you were looking for some action like 'outOfFocus' which woud have been availabl in Javascript.

But the same thing is not supported by Wd Java.

Thanks,

Jakes.

Former Member
0 Kudos

Hi All

To deselect selected row when u click again i used following code, but not working... can anyone help me please ..

data: lr_node type ref to if_wd_context_node.

data: lr_element type ref to if_wd_context_element.

data: lt_elements type WDR_CONTEXT_ELEMENT_SET.

lr_node = wd_context->get_child_node( 'HGT_EMP_CARRIER_ESS' ).

lt_elements = lr_node->get_elements( ).

loop at lt_elements into lr_element.

if lr_element->is_selected( ) is not initial.

lr_element->set_selected( abap_false ).

exit.

endif.

endloop.

Thanks,

kris.

Edited by: kissnas on Oct 19, 2010 6:05 AM

Former Member
0 Kudos

not solved. Closing this .

Former Member
0 Kudos

You may use below code to unselect the row in the table.

lo_nd_node_oa_level1->set_lead_selection_index( if_wd_context_node=>no_selection ).

Regards,

Naresh kumar

Former Member
0 Kudos

Hi Kris,

Yes, Deselection is possible in a table.

You could use CLEAR_SELECTION method of if_wd_context_node to achieve it and u could apply any logic to achieve it, you just have to use this method to do so.

Regards

Anurag Chopra

Former Member
0 Kudos

Hi Anurag

Thanks for your reply,

here i dont have any actions to call that, when user clicks out side table any place in that view or click on selected row again? how can we acieve?

Thanks,

kris.

Former Member
0 Kudos

Hi,

There could be another possiblity of achieving the same, but for the current context I think, you can maintain an attribute in the table of type WDY_BOOLEAN and set this to ABAP_TRUE when the user selects and changes any of the input field or selects a dropdown value or checks any check box, under WDDOMODIFYVIEW.

If the user doesn't make any of the above actions even after selecting, then use the CLEAR_SELECTION method of if_wd_context_node.

One of the possibilities to get the action from the table itself.

If you don't have any of the dropdowns, input fields or check boxes, let us know. Will look for further possibilities.

Regards,

-Syed.

Former Member
0 Kudos

Hi Kisan,

There are two things which you need to do

1) Capture the user action on the view, If the user clicks on the view part which doesnt have any ui element, it doesnt call wddomodifyview method of the view, I am not sure how do we capture this but we could capture if a user selects any other ui element.

2) Once you have the info on whether the user has selected a row of the table u dont have to do anything but if it selects any other ui element you could call the clear selection method of the node associated with the table.

I would not suggest that you have another variable to capture the user action, you could use the method

current_action_info of if_wd_view_controller.

Regards

Anurag Chopra