cancel
Showing results for 
Search instead for 
Did you mean: 

Add new row into table

Former Member
0 Kudos

Hello,

I have created a table with two columns which are binded to the context. At the beginning you only see one row with these two columns.

My question is how can I realize it to add a new row? In my case I want to push a button to create a second row row with the same select boxes and so on. I think there must be an easy solution to add this row but I didn't find out it.

Regards,

Frank

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Add this code to the action of the button.

IPrivate"ViewName".I"Table"Element ele = wdContext.nodeTable().createTableElement();

wdContext.nodeTable().addElement(ele);

Thanks and Regards

Leena

Former Member
0 Kudos

Thank you all for your support.

The answer Leena wrote is exactly what I am searching for. It works! Thank you for your detailed answer.

Regards,

Frank

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Frank,

Write code of creating element and binding this element to node in your action method of the button.

refer my reply in following post for the same to add new elements.

https://www.sdn.sap.com/sdn/collaboration.sdn?node=linkFnode6-1&contenttype=url&content=https://

Regards,

Bhavik

Former Member
0 Kudos

Hi Frank,

I am not very sure abt what you want, but if you just need to add a new row of data to the table :

//Create a new element of the node

Iprivate<yur_view_name>.I<Node_name>Element elmt = wdContext.create<node_name>Element();

// Set the values

elmt.set<Attribute_name>(<value>);

elmt.set<Attribute_name>(<value>);

// Add the element to the node

wdContext.node<node_name>.addElement(elmt);

Hope this helps,

Best Regards,

Nibu.

former_member182372
Active Contributor
0 Kudos

Hello Frank,

Only way to do this - add new element to context node which is mapped to datasource of table.

Best regards, Maksim Rashchynski.