cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Multiple records in Table?

Former Member
0 Kudos

Hi ..

I need to perform delete operation in my table with multiple selection.

My coding is..

for(int i=wdContext.nodeDetails2().size()-1;i>=0;i--)

{

if(wdContext.nodeDetails2().isMultiSelected(i) || wdContext.nodeDetails2().getLeadSelection()==i)

{

wdContext.nodeDetails2().removeElement(wdContext.nodeDetails2().getDetails2ElementAt(i));

}

}

When i delete first record, It works fine and multiple selection also works fine.

But when i select last record(only one) to delete, Then All the records get deleted. ???? Why this happens???

Anybody help to solve this probelm..

Thnx in advance..

Regards,

GS

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Satish,

Try putting this code

for(int i = wdContext.nodeOutput2().size()-1;i<=0;i--)

{

if(wdContext.nodeDetails2().isMultiSelected(i) || wdContext.nodeDetails2().getLeadSelection()==i)

{

wdContext.nodeDetails2().removeElement(wdContext.nodeDetails2().getDetails2ElementAt(i));

}

}

Regards,

Murtuza

Former Member
0 Kudos

Hi ..

Its Wrong i think..

i>0;--> if we give lik this ,then only the loop will get executes...

Urs GS

Former Member
0 Kudos

Hi Satish,

Did you try executing that.

I implemented the same things in one of my table when I had to delete multiple rows.

If you don't find solution correct then you can neglect that.

Ya sorry it should be >=

Murtuza

Former Member
0 Kudos

Ya.. i can delete multiple rows.. But when i click single row , then all the rows will be deleted.....

Former Member
0 Kudos

can you jus check it with by deleting last record only?

Former Member
0 Kudos

Hi Satish,

This solution is working fine on 2004 but has the problem same as being mentioned by you that it deletes all rows in case of 2004s. I think you are using 2004s.

Regards,

Murtuza

Former Member
0 Kudos

Yes.. I am using 2004s.

former_member751941
Active Contributor
0 Kudos

Hi Sathish,

Store the node size in a variable then try. To avoid problems with the index, the context is executed in reverse. Suppose in a table you have 10 rows and you are deleting row 2 the after deletion of row 2 row 3 will come to row 2,row 4 will come in row 3 in this way process will be continue up to last row.

Try this.

int n = wdContext.nodeDetails2().size();

int leadSelected = wdContext.nodeDetails2().getLeadSelection();

// loop backwards to avoid index troubles

for (int i = n - 1; i >= 0; --i) {

if (wdContext.nodeDetails2().isMultiSelected(i) || leadSelected == i) {

wdContext.nodeDetails2().removeElement(wdContext.nodeDetails2().getDetails2ElementAt(i));

}

}

Regards,

Mithu

Answers (0)