cancel
Showing results for 
Search instead for 
Did you mean: 

How to get different values in drop down in table rows

former_member187658
Participant
0 Kudos

Hi

I have an application, which has a drop down in the table. Each row is to have different values in its drop down based on the "characteristic" parameter. For eg. first row has characteristic as color, and the corresponding drop down will contain the color names. Second row has charateristic as weight, and the drop down will carry corresponding weight values.

I am getting the data from the backend as a flat table i.e. charaterisitc - value pair.

I think i will have to use the Drop Down by Index control, but i dont know how exactly to go about it.

Can any one please help in this regard.

Thanks & regards,

Anupreet

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Anupreet,

Right, you should use drop down by index. Create context node under your datasource node with appropriate attributes and make it singleton false and cardinality 0..n. Add column to table. Insert cell editor as drop down by index and bind attribute from new created node to appropriate property from drop down.

Best regards, Maksim Rashchynski.

former_member187658
Participant
0 Kudos

Hi

I did exactly as per what you said, but now, it shows all the values in the first row's drop down (including the entries for the second row drop down). And second row's drop down is coming as blank. Is any code to be written further for this whcih will be executed at runtime?

The first column, based on which drop down values are to be displayed is not a drop down. It contains a single value only each row, like a normal cell data.

Thanks & regards,

Anupreet

former_member182372
Active Contributor
0 Kudos

Hi Anupreet,

When you are populating node with data fro drop down you should not use current<dataSourceNode>Element but for every node element.


	IWDNode node = wdContext.nodeDisplayTable();
	final int size = node.size();
	
	for (int i = 0; i< size; i++)
	{
		final IWDNodeElement _element = node.getElementAt( i );
		...
	}

Best regards, Maksim Rashchynski.

former_member187658
Participant
0 Kudos

Hi Maksim

I am sorry, but i am not able to get you.

This is the piece of code that i wrote for populating the drop down:

IPrivateMaintainDocAttribView.IDropElement dropEle = null;

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

{

dropEle = wdContext.nodeDrop().createDropElement();

dropEle.setDropval(wdContext.nodeCtxNode_DocAttribs().getCtxNode_DocAttribsElementAt(i).getCmpCtx_Value());

wdContext.nodeDrop().addElement(dropEle);

}

Here, Dropis the sub node to which i am putting the data and thisis linked to the table.

CtxNode_DocAttribs is the model node from where i am picking the data and setting in the subnode.

Thanks & regards,

Anupreet

former_member182372
Active Contributor
0 Kudos

Hi Anupreet,

Try this

	IPrivateResult.ICtxNode_DocAttribsNode node = wdContext.nodeCtxNode_DocAttribs();
    int size = node.size();
	IPrivateResult.INodeDropElement dropEle;
	
    for(int i =0;i<size;i++) {//for every element in CtxNode_DocAttribs node
		IPrivateResult.INodeDropNode subnode = node.getCtxNode_DocAttribsElementAt(i).nodeNodeDrop();
		for(...) {//for every item in drop down	
			dropEle = subnode.createNodeDropElement();
			dropEle.setDropval( ... );
			subnode.addElement(dropEle);
		}
    }

former_member187658
Participant
0 Kudos

Hi Maksim

I tried the code provided by you. But it shows multiple rows and each row's drop down contains all the values besides, one blank element is added to the list with each iteration. Foreg. if my table contains 2 rows, the drop-down column shows 6 rows carrying the drop downs, and each one is having all the values plus one blank element added for each one of them additionally. Even though the first column shows data in only 2 rows as it is supposed to display.

Thanks & regards,

Anupreet

arun_srinivasan
Contributor
0 Kudos

hi,

To remove the blank value in the dropdownbyindex , Set the Selection Property of dropdown Node to 1..1 or 1..n

Hope this helps,

Thaks and regards,

Arun

former_member187658
Participant
0 Kudos

Hi

Can anyone suggest something in this regard please??

Thanks & regards,

Anupreet

Former Member
0 Kudos

Hey Anupreet.. did you find any solution to your problem.. I am stuck with the same scenario... if you can help...

Answers (1)

Answers (1)

Former Member
0 Kudos

Anupreet,

1. Use drop-down by index

2. For this UI control create child node of cardinality 0..n, singleton=false right under node that is used as table data source.

VS