cancel
Showing results for 
Search instead for 
Did you mean: 

Delete a row from the table

Former Member
0 Kudos

Hi,

Can any one tel me How to delete a row on selecting a particular row in a table from Webdynpro.Currently i am display a table during design time and data gets populated at run time and now I want to delete a row on select of that particular row by user.

Please help me out..

Thanks,

Kavitha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kavitha,

Since you are populating the table dynamically, a row within it can be easily deleted.

Create a button called Remove. This should be visible only when a row is selected. You can achieve that by creating an attribute of type Visibility and binding the visible property of the Remove button to this attribute. You can then set the Visibility attribute using this code where required,


wdContext.currentContextElement().setDownloadButtonVisibility(
				WDVisibility.VISIBLE);

Create a new action called Delete and set the onAction property of the Remove button to this action.

Inside that onActionDelete() event handler, you can write something like this,


int i = wdContext.nodeCategory().getLeadSelect();
for(int i=0;i< wdContext.nodeCategory().size();i++){
       IPrivateView.INodeCategory node = wdContext.nodeCategory();
       IPrivateView.IElement element = wdContext.nodeCategory().getCategoryElementAt(i);
       if(wdContext.nodeCategory.isSelected(i)){
                node.removeElement(element);
}
}

Hope this helps!

Regards

Kishan

Edited by: kishan chandranna on Dec 29, 2008 11:18 AM

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks to ramesh and Fazal..

Former Member
0 Kudos

Hi All,

Can any one tel me how can i add checkbox to the table and on selecting those checkbox that particular row should get delete?

Thanks

Kavitha

Former Member
0 Kudos

Hi,

when u apply a table template u can change the cell editor type as a checkbox

and in the on toggle event u can implement the logic u want.

Regards,

Satya.

Former Member
0 Kudos

Hi,

For Table UI add one TableColumn and right click on the TableColumn and select the inserTableCellEditor from the menu and from the available options select the checkbox.

and for checkbox you can find the onToggle event to fire the action.

Regards,

ramesh

former_member201361
Active Contributor
0 Kudos

hi,

create a boolean Attribute and bind it ot the Check box.

if the User selects the check box and clicks on the button remove , we have to remove the checked rows. for this open the Java Editor of the View and in the OnAction method of the Button"remove" , implement the functionality to remove the checked rows .

Thanks and regards

Former Member
0 Kudos

HI

please find the code.

public void onActionClearSelected(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionClearSelected(ServerEvent)

for(int i=0;i<wdContext.nodeCopyAllNode().size();i++)

{

if(wdContext.nodeCopyAllNode().isSelected(i))

{

wdContext.nodeCopyAllNode().removeElement(wdContext.nodeCopyAllNode().getElementAt(i));

}

}

//@@end

}

regards

Manohar

Former Member
0 Kudos

Hi All,

Thanks to all of you for your immediate reply. I will try and incase I didn get will get back to you..

Thanks,

Kavitha

Former Member
0 Kudos

Hi,

int i = wdContext.node<yournoe>().getLeadSelect();

for(int i=0;i< wdContext.node<yournoe>().size();i++){

IPrivateView.Inode<yournode> node = wdContext.node<yournoe>();

IPrivateView.IElement elem = wdContext.node<yournoe>().get<yournode>ElementAt(i);

if(wdContext.node<yournoe>.isSelected(i)){

node.removeElement(elem);

}

}

Regards,

Satya

former_member201361
Active Contributor
0 Kudos

hi,

Add a Button say "Remove" in the View .

Create a Action and bind the action to the OnAction Property of the Button.

In the Java editor of the View, remove the Current Selected Row

for eg :

if (wdContext.nodeTableNode.currentytableNodeElement != null){

wdContext.nodeTableNode.removeElement(wdContext.currentTableNodeElement);

}

where TableNode is the value node bound to the Datasource property of ur table

Hope it helps

Thanks and Regards