cancel
Showing results for 
Search instead for 
Did you mean: 

leadselect and toolbarbutton

Former Member
0 Kudos

hi,

i have got a table with a toolbarbutton.

How do I perform the action of the toolbarbutton with the selected row?

I need a delete action.

Do I first have to perform a leadselection action, which puts the selected row in the current RowContext, and then when hitting the button perform the delete with the data stored in my RowContext?

or is there another more elegant way?

is there xtra trouble when allowing a multi-select on the table?

thanx,

matthias

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi matthias ,

For deleting multiple selected values you can use the following

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

{

if(wdContext.nodeData().isMultiSelected( i))

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

}

Regards, Anilkumar

Former Member
0 Kudos

Almost. When removing node elements in a loop, the indices of the node elements change. To avoid those index troubles, simply loop backwards.

Armin

Former Member
0 Kudos

Hi Armin,

Wow! Details so intricate ...But so important ! Great Armin ! :)Never thought abt these details !

But if the index are changing in while we are deleting.. it will throw a indexoutofbounds exception while the whole loop is executed...

But it has never happened to me that way ! The deletion had always worked..how is that? Is it like it deletes them first from a copy of values and then commits them ...

Message was edited by: Bharathwaj R

Answers (2)

Answers (2)

Former Member
0 Kudos

What should be "a more elegant way"?

In the action handler of the toolbar button, check which table rows (node elements) are (lead or multi-) selected and remove them from the node.

Armin

Former Member
0 Kudos

Yes.

First you have select the row that you want to delete and then on click on button you can delete the selected row element.

use

wdContext.node<<NodeName>>().removeElement(wdContext.current<<NodeName>>Element());

Regards, Anilkumar

Message was edited by: Anilkumar Vippagunta