cancel
Showing results for 
Search instead for 
Did you mean: 

How to append a row to existing rows in a table

Former Member
0 Kudos

hi

ihave 5 rows in atable as soon as i click on a button another row should be appended to existing rows.and when i click on another button the selected row should be deleted.

Thanks

kishore

Accepted Solutions (0)

Answers (4)

Answers (4)

nikhil_bose
Active Contributor
0 Kudos

Add Rows:

1) create a table element type


  IPrivate<Comp>.I<TableNode>Element newelement = wdContext.create<TableNode>Element();

2) Add element to node


 wdContext.node<TableNode>().addElement( newelement);

Delete Rows:

Better way is find the element which is selected.

1) find lead selected element and remove it.

OnActionDelete

.node<TableNode>(). element;

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

element = (IPrivate<Comp>.I<TableNode>Element) wdContext..node<TableNode>().getElementAt(i);

if(wdContext.node<TableNode>().isSelected()) {

wdContext.nodeCart().removeElement( element);

}

}

nikhiL

Former Member
0 Kudos

Hi,

You can add/remove row from a table on the action of some button.For this you need to add two buttons inside the table by using buttonrow element..Use buttons for adding/deleting rows from table.

Steps to add a row in a table:

Step 1: Declare a action method on action of add button.

Step 2: Inside the action method, write following piece of code

I<TableNodeName>Element objTableElement=wdContext.node<TableNodeName>().createElement();

wdcontext.node<TableNodeName>().add(objTableElement);

Steps to delete a row from table:

Step 1: Declare a action method on action of delete button

Step 2: Inside the action method, write following piece of code

if(wdContext.node<TableNodeName>().size()>0)

{

int selectedElement=wdContext.node<TableNodeName>().leadSelection();

I<TableNodeName>Element objTableElement=wdcontext.node<TableNodeName>().get<TableNodeName>ElementAt(selectedElement);

wdContext.node<TableNodeName>().removeElement(objTableElement);

}

regards,

amit bagati

Former Member
0 Kudos

Add row:


IWDNodeElement element = wdContext.nodeMyTable().createElement(<ModelObject>); (model node)
wdContext.nodeMyTable().addElement(element);

Remove row:


IWDNodeElement element = wdContext.nodeMyTable().getCurrentElement();
if (element != null) {
    wdContext.nodeMyTable().removeElement(element);
}

Both in the action-methods of your buttons.

former_member201361
Active Contributor
0 Kudos

Hi,

I dont thibk adding a row to the Existing row is not possible .

and u can delete the row of a table by just deleting the TableNodeElement for the particular row .

U can add a row to a table onClick of a button.

For eg :

In the OnAction Method of the Button use this code.

ITableNodeElement element = wdContext.currentTableNodeElement;

wdContext.nodeTableNode.removeElement(element);

Thanks and Regards

Fazal B