cancel
Showing results for 
Search instead for 
Did you mean: 

Populating Table UI element

Former Member
0 Kudos

Hi,

I want create a table with 3 rows and 3 columns and I want to display some values/test in the fields(at design time).

I'm having difficulty in populating values in the table. How to display values ? Pls help me with detailed steps

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

1. First create a table.click on it....click on "create binding". Attach it to a node with 3 attributes. The attributes get populated as columns. Now select input field for that.

2. To get 3 rows : set the "element property" --->visibleRowCount = 3.

3.Now you can enter data into the table and save the values in another table or 3 arrrays, as you please.

lets, say you attched EmpNode with attributes, EmpName, EmpAge and EmpId

if you have to dynamically enter the data,

then,


for(int i=0;i<wdContext.nodeEmpNode().size();i++)
{
	IEmpNodeElement element =
	wdContext.nodeEmpNode().getEmpNodeElementAt(i);

	
	if(i==0)
{
element.setEmpName("name1");
element.setEmpAge("age1");

}
 if(i==1)
{
//add code for row 2}

if(i==2)
{
//add code for row3
}


}

regards,

pinki

Former Member
0 Kudos

Hi

I've used the same code but at run time its populating only one row. its not populating other two rows.

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

IPrivateLogin_DCView.IEmpElement empele= wdContext.nodeEmp().getEmpElementAt(i);

if(i==0){

empele.setEmp_name("Deepa");

empele.setEmp_age("35");

empele.setEmp_no("SAP GDC No 1");

}

if(i==1){

empele.setEmp_name("Raju");

empele.setEmp_age("32");

empele.setEmp_no("INFO 1");

}

if(i==3){

empele.setEmp_name("Rose");

empele.setEmp_age("42");

empele.setEmp_no("retired ");

Former Member
0 Kudos

Hi Rajasekhar,

sorry

i.e IPrivateView1.IEmpElement ele;

Regards

Hazrath

Former Member
0 Kudos

I've used the below code to populate 3 rows , but at run time I seeing only first row populated , why the second and third rows are not populating?

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

IPrivateLogin_DCView.IEmpElement empele= wdContext.nodeEmp().getEmpElementAt(i);

if(i==0){

empele.setEmp_name("Deepa");

empele.setEmp_age("35");

empele.setEmp_no(" 1");

}

if(i==1){

empele.setEmp_name("Raju");

empele.setEmp_age("32");

empele.setEmp_no("INFO 1");

}

if(i==2){

empele.setEmp_name("Rose");

empele.setEmp_age("42");

empele.setEmp_no("454 ");

}

}

Answers (4)

Answers (4)

former_member751941
Active Contributor
0 Kudos

Hi Rajashekhar,

1> Take 3 context attributes

i> name

ii> no

iii> sal

2> Take a value Node <b>Employee</b> under the context

Unter the Employee value node take 3 Value Attribute

i> ename

ii>eno

iii>esal

Design a View like this way :

Enter Employee Name : name (inputfield)

Enter Employee No : no (inputfield)

Enter Employee Salalary : sal (inputfield)

AddRow(Button)

ename |eno |esal

-


Employee.ename |Employee.eno|Employee.esal

-


Employee.ename |Employee.eno|Employee.esal

-


Employee.ename |Employee.eno|Employee.esal

-


Inside the action of AddRow Button write the code

public void onActionAddRow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionAddRow(ServerEvent)
    IPrivateTestCompView.IEmployeeElement empElm = wdContext.createEmployeeElement();
          empElm.setEname(wdContext.currentContextElement().getName());
	empElm.setEno(wdContext.currentContextElement().getNo());
	empElm.setEsal(wdContext.currentContextElement().getSal());
   wdContext.nodeEmployee().addElement(empElm);
	
              wdContext.currentContextElement().setName("");
	wdContext.currentContextElement().setNo("");
	wdContext.currentContextElement().setSal("");
    //@@end
  }

Regards,

Mithu

former_member201361
Active Contributor
0 Kudos

hi,

use this code

here patentlistnode is the node element and its attributes are serial number,title,statusand number.

for(int i=1;i<20;i++){

IPatentListNodeElement patentElement = wdContext.createPatentListNodeElement();

patentElement.setSerialNumber(i);

patentElement.setTitle("Patent Title"+i);

patentElement.setStatus("Approved"+i);

patentElement.setNumber("Number"+i);

wdContext.nodePatentListNode().addElement(patentElement);

}

rightClick >source>organize imports .

will import the necessary class and it will remove the errors.

thanks and regards

fazal

Former Member
0 Kudos

Hi

You can create contextElements and bind to the Table UI Element. On code you can assign values to the Context element that will be shown in table.

Remember that you must create a context Node first and then create the three Context elements under the node that you created before.

To assign values to Context.


IPrivateXxxView.ITableMonthDetailsNode node = wdContext.nodeTableMonthDetails();
    	IPrivateXxxView.ITableMonthDetailsElement element;
		
		for( int i = 0; i < 10; i++)
		{
			element = wdContext.currentTableMonthDetailsElement();
			element.setFIDocNo( i);
                        element.setFiDocDate( "12/" + i + "/2008");  
			
			node.addElement( element);
		}

Regards

- Vinod

*

Edited by: Vinod V on Mar 28, 2008 12:03 PM

Former Member
0 Kudos

Hi

1)take a ui element table

2)create a valuenode Emp

3)Create a value attributes empno,ename under Emp value node

4)then attach the table datasource property to the emp node

4)Then fill the table with data

IPrivateview1.IEmpnode node1=wdContext.nodeEmp();

IprivateEmpelement ele;

ele=node1.createEmpElement();

ele.setEmpno("1");

ele.setEname("name1");

node1.addElement(ele);

like the above u can add so many rows

where view1 is the viename

Regards

Hazrath

Former Member
0 Kudos

IprivateEmpelement ele;

can u check this second step bcz its giving error for me.

its not allowing to create element object