cancel
Showing results for 
Search instead for 
Did you mean: 

dynamically adding rows to a statically created table

Former Member
0 Kudos

Hi

I have a scenario in which i need to add rows dynamically to a statically created table that is

i have a table employee wid columns name and location

ill have two input fields along wid the table wen i press on save the information i have entered inthe input field should be added in the table

is this scenario possible

Regards

Nikhil Tapkir

Edited by: Nikhil Tapkir on Sep 10, 2008 6:43 PM

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Nikhil,

If I understand your requirement correctly, you have two columns name and location in the table and two input fields beside the table.

You want to add the the data entered in the two input fields into table.

Try like this:

In onActionSave()

I

Private<viewname>.I<table>Node node = wdContext.node<table>();
IPrivate<viewname>.I<table>Element element = node.create<table>Element(); 
ele.setName(wdContext.currentContextElement().get<attributename bind to the name input field>);
ele.setLocation (wdContext.currentContextElement().get<attributename bind to the location input field>);
node.addElement(element);

Regards

Siva

vmadhuvarshi_
Contributor
0 Kudos

Nikhil,

If the table is bound to a Node and Table columns represent Node Attributes, you can use this example to add another row to table. Create another context structure similer to that in table to hold the values to be added, create a Form based on this new structure, add a button and onActionEvent of this button write something like this.


public void onActionAddProduct(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionAddProduct(ServerEvent)
	  IProductsElement product = wdContext.createProductsElement();

      product.setARTICLE(wdContext.currentContextElement().getARTICLE());
      product.setCOLOR(wdContext.currentContextElement().getCOLOR());
      product.setCURRENCY("EUR");
      product.setSIZE(wdContext.currentContextElement().getSIZE());
      product.setORDER_NUMBER(wdContext.currentContextElement().getORDER_NUMBER());
      product.setPRICE(wdContext.currentContextElement().getPRICE());
      product.setSPECIAL_FEATURES(wdContext.currentContextElement().getSPECIAL_FEATURES());
      product.setTEXTILE_CATEGORY(wdContext.currentContextElement().getTEXTILE_CATEGORY());

      wdContext.nodeProducts().addElement(product);
    //@@end
  }

New line will be added to the table and will be visible as last line because a server round trip is involved due to action event. This code sample extends [sample Table project|https://www.sdn.sap.com/irj/sdn/nw-ui?rid=/webcontent/uuid/503f22f6-b978-2a10-bf97-ddc21267e752#46].

Hope this helps.

Vishwas.

PS: I liked your article about Fetching User Details.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

the table you created is bound to a context node. This node is for example:

ParentNode

employeeAttribute

locationAttribute

So the only thing you have to do is to add the coding to create a new element and set the values from the input fields in the node attributes.

Regards,

Martin