Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Sample code is required on how to use TableUI element in ArrayList

Hi all

Can any body send the sample code on how to store Table UI element in Arraylist.

Regards

Suresh babu

replied

Hi I am providing two methods of it. Just go through and try. This will defenately solve your problem

I. METHOD

Try This

//@@begin others

//this is the array used in the program

String emp[][]=

{

{"nikhil","tapkir","pune"},

{ "juhi","bhatnagar","delhi"},

};

//@@end

}

i have to insert the above information in a table wid columns firstname lastname and city .

u need to use the for loop to insert the data in the table for more than 1 record

code the following thing in wd init

here fname lname and city are my value attributes mapped to my table columns.

for (int i=0;i<emp.length;i++)

{

IPrivateTabappView.ITablenodeElement tnode=wdContext.createTablenodeElement();

tnode.setFname(this.emp<i>[0]);

tnode.setLname(this.emp<i>[1]);

tnode.setCity(this.emp<i>[2]);

wdContext.nodeTablenode().addElement(tnode);

}

i hope this is what ur doubt was if not pls clarify.

hope this helps u.

II METHOD

For example: Consider that the value node DataNode having two attributes A and B is bound to the DataSource property of your Table UI Element.

IDataNodeElement objDataNode = null;

ArrayList arlDataNode = null;

int size = 0;

size = <No. of rows that you want in the table>;

arlDataNode = new ArrayList();

for(int i=0;i<size;i++)

{

objDataNode = wdContext.createDataNodeElement();

objDataNode.setA(<Set some values>);

objDataNode.setB(<Set some values>);

arlDataNode.add(objDataNode);

}

wdContext.nodeDataNode.bind(arlDataNode);

Hope, You can resolve your problem. Revert me if you have any doubts.

Regards

Raghu

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question