cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove multiple rows from table

Former Member
0 Kudos

Hi All,

in my application iam using two tables,

this is my code

int selection = wdContext.nodeA().getLeadSelection();

String num = wdContext.nodeA.geAAt(selection).getV_Num();

for(int b=0;b<wdContext.nodeVn_Context().size();b++)

{

if(wdContext.nodeVn_Context().getVn_ContextElementAt(b).getVa_num().equalsIgnoreCase

(num))

{

wdContext.nodeVn_Context().removeElement(wdContext.nodeVn_Context().getVn_ContextElementAt(b));

}

}

here Vn_Context is having 4 rows, i mean size of Vn_Context is 4. when i use this code to remove that 4 rows based on the condition, which i gave in if, its able to remove only one row, so how to remove those four rows, is this code correct or not, please help me.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hello Sushma,

Assuming that your node allows multi-selection, use the following method:

Loop over the elements and select each element using the setSelected() method, according to your condition, eg.


wdContext.nodeXXX.setSelected(idx, true/false)

At the end of the loop call the method removeSelectedElements().


wdContext.nodeXXX.removeSelectedElements();

Walter

Former Member
0 Kudos

Hi,

Try this code,

for (int i = wdContext.node<Node>().size() - 1; i >=0; --i)

{

I<Node>Element e = wdContext.node<Node>().get<Node>ElementAt(i);

if ( condition_to_delete(e) )

wdContext.node<Node>().removeElement(e);

}

Regards,

Sunaina Reddy T

ravindra_bollapalli2
Active Contributor
0 Kudos

hi sushma,,

refer this thread

let me know u need any further info

bvr

NarendraChandel
Contributor
0 Kudos

Hi Sushma,

please follow the below link

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/5f699f90-0201-0010-14a4-89501772...

page no 17 explains how to delete multiple rows.

regards

Narendra

Edited by: Narendra Singh on Apr 27, 2009 8:19 AM

Former Member
0 Kudos

Hi,

Write this code in your method.



int n = wdContext.nodeA().size();
int leadSelected = wdContext.nodeA().getLeadSelection();
String num = wdContext.nodeA.geAAt(selection).getV_Num();



	
		// loop backwards to avoid index troubles
		for (int i = n - 1; i >= 0; --i) 
{
if(wdContext.nodeVn_Context().getVn_ContextElementAt(b).getVa_num().equalsIgnoreCase
(num))
{

		  if (wdContext.nodeA.isMultiSelected(i) || leadSelected == i) 
{
			wdContext.nodeA().removeElement(
			  wdContext.nodeA().getElementAt(i));
		  }
		}
}

Thanks

Abhilasha

Edited by: Abhilasha Dahare on Apr 27, 2009 7:24 AM

former_member182416
Active Contributor
0 Kudos

hi

instead of the forward loop , try reverse loop.

Regards

Rajendra