cancel
Showing results for 
Search instead for 
Did you mean: 

How to swap positions of drop down box values

Former Member
0 Kudos

HI,

I hae a drop down box filled with values from my database..

now i need to swap positions in the order of the values in drop down box (ie) like i neeed my 3rd element in the drop down should be first in the list ..

How can i swap positions in drop down box..

Kindly help..

Thanx,

Arjun.G

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you are using DropDownByIndex, just swap the corresponding node elements in the context node (say it's named "Items"):

wdContext.nodeItems().swapElements(0, 2);

Armin

Former Member
0 Kudos

Hi,

I have solved the swap issue...

Now my issue is like ,, i have the drop down in table , so if i select a value in a dropdown of single row , it reflects in all drop down fields of the table ..

Hw to overcome this,...

thanx.

Arjun.G.

Former Member
0 Kudos

The node that stores the items of the drop-down list must be a non-singleton child node of the table's data source node.

Armin

Former Member
0 Kudos

Hi,

This is because all the table row point to the same element of the drop down.

If you look at table concept wise

each row inside the table is an element of the node which is bound to it.

So In your case as you have a different context for the dropdown, which is not getting created for each row.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

In my case Its getting created for each row ohly...

ie if i have 1 record in my table it gives drop down for that row only...

is ther any way to overcome this.....

Thanx.

Arjun.G

Former Member
0 Kudos

Make "Items" a non-singleton child node of "Rows". Fill "Items" with code like


/* To fill drop-down list in row at index i: */
IRowsElement row = wdContext.nodeRows().getRowsElementAt(i);
for (int j = 0; j < num_items_in_row_i; ++j)
{
  IItemsElement item = row.nodeItems().createItemsElement();
  item.setText("Item #" + j + " in row #" + i);
  row.nodeItems().addElement(item);
}

Replace "Items" and "Rows" by the names of your context nodes.

Armin

Former Member
0 Kudos

HI Armin,

Thanx a lot for ur support...

I got my issue resolved...

Thanx once again...

Arjun.G

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Create a comparator of your own and sort the node using that

wdContext.nodeTest().sortElements(Comparator arg)

Regards

Ayyapparaj

Former Member
0 Kudos

HI,

I have used the set leadselection method and got my issue resolved...

Nw i have a issue that , i have placed the dropdown in the table ,so if i select one drop down value in the table, entire table column is filled with that value... that should not happen ..

Hw to fix it...

Thanx.

Arjun

Former Member
0 Kudos

Hi,

Can you explain your context structure .and the bindings to the table, then it will be easy.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

Table is bounded to two nodes,

node 1: (for general text view UI elements in the table)

attributes:

groupid

group name

cardinality:0-n

selection:1-1

node 2:(for drop down UI element)

attributes:

categoryid

cardinality:0-n

selection:1-1

Thanx.

Arjun.G

Former Member
0 Kudos

If you want to swap the values do it in the back end system making use of the value on which you want to sort.As soon as the values are displayed sorted as per your requirement in ascending or descending.

Former Member
0 Kudos

You can use setLeadSelection() for setting the first value of dropdown, i.e., setLeadSelection of the node bound to your dropdown.