cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic table with dynamic drop-down list values

Former Member
0 Kudos

Hi,

I need to display a dynamic table with 2 columns on an interactive form.

My Context is defined as below:

Root

-


StudentData 0..n

-


StudentName

-


StudentCourses 0..n

-


Text

-


Value

The 1st column should display student name, 2nd column should display student courses. The courses will be different for each student. I populated the context properly. I checked it by printing them. My DDL is bound to "Student Courses".

When there is one row -> The DDL is populated with the courses of student 1 (as there is only one).

When there are more rows -> The DDLs for all the students are populated with all the courses of all the students.

I want to see the data populated like:

TEXTFIELD DROP-DOWN LIST

Student 1------Student1-Course1

-


Student1-Course2

-


Student1-Course3

Student 2------Student2-Course1

-


Student2-Course2

-


Student2-Course3

I tried to do this in plain web dynpro using SVS.. it is also working similarly.

I have set the singleton property of nodes "StudentData" and "StudentCourses" to false.

Could any one tell me where I am going wrong?

Thanks

Ram

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Ram,

I'm not sure how much this will help, but I know I had the same problem as you when I tried to get a similar thing working, but I can't remember which of the many changes I made fixed the problem, so I'll just show you my code and perhaps you can see if anything is different than yours.

Here's where I'm creating my dropdown - in my case EastNew_RegOut is the same as your StudentData, and RateTypeDropValues is the same as your StudentCourses (the comments in the code are not meant to sound bossy to you, this is actually an example piece of code that other developers in my company "steal", so I have to put very specific instructions in there!):

int nodeSize = wdContext.nodeEastNew_RegOut().size();
for (int i = 0; i < nodeSize; i++) {
	//create an element called "table", that's the element at i.  So, basically it's a row.  Maybe I should have
	//called it "row" instead of table.
	IPublicDeviceExchange.IEastNew_RegOutElement table = (IPublicDeviceExchange.IEastNew_RegOutElement)wdContext.nodeEastNew_RegOut().getElementAt(i);
	//this line of code just executes an rfc that finds out what rates need to be in the dropdown for this particular row 
	executeRateTypeDropdown(rateCategory, table.getNum(), wdContext.currentEastNew_MeterOutElement().getReggrp());
	
	//clear out what's already in there before we re-populate it.
	table.nodeRateTypeDropValues().invalidate();
	//now, I'm looping through all the values in the *actual* rate type dropdown (the one that's an RFC, populated by the above "execute" method)
	for (int j = 0; j < wdContext.nodeEastRatetype_DropdownOut().size(); j++) {
		//for each element in the *actual* Rate type dropdown, I'm going to create an element in my node that I created
		//and set the values from the *actual* one as the values in my node.
				IPublicDeviceExchange.IRateTypeDropValuesElement element = wdContext.createRateTypeDropValuesElement();
	
		IPublicDeviceExchange.IEastRatetype_DropdownOutElement rateTypeOut = (IPublicDeviceExchange.IEastRatetype_DropdownOutElement)wdContext.nodeEastRatetype_DropdownOut().getElementAt(j);
		element.setText(rateTypeOut.getText());
		element.setValue(rateTypeOut.getRatetype());
				
		//here's another key - notice how I don't say wdContext.nodeRateTypeDropValues() - it's the one that's
		//directly off that table I created earlier - the thing that's essentially a row in my newReg table.
		//So, what I'm doing here is adding that new element I created to the dropdown FOR THAT ROW!			
		//(btw, if you're trying to duplicate this, and this method does not exist for your "table" object, it's 
		//probably because you didn't listen to me above and you didn't create your node with the singleton property
		//set to false.)
		table.nodeRateTypeDropValues().addElement(element);
	}
		
}

As for my layout... my table is bound to the EastNew_RegOut node, and the column with the dropdown is bound to RateTypeDropValues.Value (that's probably obvious, but there you have it anyway)

Finally, in my context, EastNew_RegOut is singleton = true (I was surprised about this, actually, I would have assumed it was false) with a selection of 0..1 and RateTypeDropValues has singleton set to false with a selection of 0..1

I hope that helps to some degree!

Jennifer

Former Member
0 Kudos

Jennifer,

Thanks much for your quick response. I tried your code and it is still not working.

I maintained the context structure as yours and wrote the below code in wdDoInit()method of the View.

// Create 2 rows

for (int i = 0; i < 2; i++) {

IPrivateWDQuickTestView.IEastNew_RegOutElement table = wdContext.createEastNew_RegOutElement();

wdContext.nodeEastNew_RegOut().addElement(table);

table.nodeRateTypeDropValues().invalidate();

// Create 2 drop-down list values for each row

for (int j = 0; j < 2; j++) {

IPrivateWDQuickTestView.IRateTypeDropValuesElement element = wdContext.createRateTypeDropValuesElement();

element.setText("Text " + i + "-" + j);

element.setValue("Value " + i + "-" + j);

table.nodeRateTypeDropValues().addElement(element);

}

}

I am still seeing the 4 values "Text 0-0", "Text 0-1", "Text 1-0", "Text 1-1" in both the drop-downs.

You might have done something more to make it work properly.. I wish you can recollect it.

Thanks

Ram

Former Member
0 Kudos

Well, now I'm really confused I took your code and copy/pasted it into a brand new view with nothing in it yet and created the same two context nodes... and everything worked for me! The only thing that's different between the two is the name of the view... I took some screenshots...

Here's my <a href="http://www.squeept.com/iffles/context.jpg">context</a>, here's my <a href="http://www.squeept.com/iffles/wdDoInit.jpg">wdDoInit</a>, and here's the <a href="http://www.squeept.com/iffles/screenshot.jpg">final result</a>.

Perhaps there's a bug in your version? I'm using NetWeaver 2004s SP 9 (or, if you do Help/About in NDS: 7.0.09)

Former Member
0 Kudos

Jennifer,

Hmmm... I would appreciate if you could please zip the code and send to me at rammohan6@gmail.com? Sorry if I am asking for too much.

Thanks

Ram

Former Member
0 Kudos

No problem! I just sent it

Former Member
0 Kudos

Hi Jennifer,

It is working fine in a plain web dynpro table but it is not working in a table insider Interactive Form. Thanks for sending the code anyway.

Thanks

Ram