cancel
Showing results for 
Search instead for 
Did you mean: 

Creating different dropdown lists for same column in a table

shani_ozeri
Participant
0 Kudos

Hi All,

I could not find such scenario described in the forum, I hope you can help me on this:

I have a table with three columns:

Column 1: Type -> Could be A or B.

Column 2: Name -> Some strings.

Column 3: Number -> A dropdown list of numbers.

Every element (row) in my node (table) can be either of type A or B. Depending on the type of the element, I need to show a different dropdown list (meaning I have two dropdown lists).

No matter what I try to do, both lists end up in the same dropdown list for both types.

Any ideas on how I can solve this ?

Thank you,

Have a wonderful day,

Shani

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Context:


Rows (node, c=0:n)
-- Items (node, c=0:n, s=0:1, singleton=false)
---- text (string)

If you use this context structure, each row ("Rows" node element) has its own "Items" node. Thus every drop-down list table cell editor can have different entries per row.

For your special case you could implement a supply function "supplyItems" for node "Items" that checks the type of the parent "Rows" element and supplies its entries accordingly:


void supplyRowsItems(IRowsElement parent, IItemsNode node)
{
   if (isTypeA(parent))
   {
     // fill node with items for type A row
   }
   else if isTypeB(parent))
   {
     // fill node with items for type B row
   }
}

Armin

shani_ozeri
Participant
0 Kudos

Hi Armin,

Thank you for your quick response, but I'm afraid I did not understand how to use your answer in my code.

Maybe I should be more specific in my description.

In my code, I define the dropdown list the following way:

IWDAttributeInfo attribSystInfo = wdContext.nodeSystemMappingData().getNodeInfo().getAttribute("NewSystem");

ISimpleTypeModifiable systType = attribSystInfo.getModifiableSimpleType();

systValueSet = systType.getSVServices().getModifiableSimpleValueSet();

After the definition, I just put the values I want in the systValueSet.

The value I show in this column may be one of the values from the list or an empty value in case that the user did not choose one of the values.

How can I bind two different lists to the same dropdown object ?

How can I do this using a supply function ?

Thank you,

Have a great day,

Shani

Former Member
0 Kudos

With a DropDownByKey as table cell editor you cannot achieve different list entries per row because the data type that stores the value set is the same for all rows. Therefore I propose a solution based on DropDownByIndex.

Just implement the supply function such that the subnode is filled with the list entries depending on its parent element (as my code sketches). If you want to have an empty entry in the list, set the selection cardinality of the subnode to 0:1.

Armin

shani_ozeri
Participant
0 Kudos

Is this relevant for both 700 and 710 ?

How can I use the DropDownByIndex ?

Thanks,

Shani

Former Member
0 Kudos

My solution can be used in all releases. Just bind the DropDownByIndex.texts property to the Rows/Items/@text attribute.

Armin

shani_ozeri
Participant
0 Kudos

Hi Armin,

Thank you very much for your great reply !

I am sorry I did not award you with points until now, but I was out of office for a very long time and did not have the chance to check your suggestion.

Now, that I've tried using the DropDownByIndex instead of DropDownByKey, I am still having some issues with the DropDownLists.

I am still using:

IWDAttributeInfo attribSystInfo = wdContext.nodeItems().getNodeInfo().getAttribute("text");

ISimpleTypeModifiable systType = attribSystInfo.getModifiableSimpleType();

systValueSet = systType.getSVServices().getModifiableSimpleValueSet();

and fill the systValueSet with the list values inside the supply method.

Can the above code be also used for DropDownByIndex ?

The problem is that the systValueSet contains the values of the list, but in runtime the dropdown list is empty.

Can you please help me find the missing step ?

Thank you,

Have a great day,

Shani

Former Member
0 Kudos

No, the binding model for DDByIndex and DDByKey are completely different. For a DDByIndex, put your item texts as elements into the context node and use the selected index (lead selection) to determine the key.

Armin

shani_ozeri
Participant
0 Kudos

I was finally able to seperate the two lists

Thank you !!

But now I have another issue:

Since I am using the DDByIndex instead of the DDByKey, I can have only one value in the table instead of a key and value (when using DDByKey).

The thing is, that I need to "show" the user a value string that represents a key string (which I need to use eventually...).

Is there a way to do this using the DDByIndex ?

Shani

Former Member
0 Kudos

What's the problem? Just store the text to be displayed in the context attribute to which you bind the "texts" property of the DDByIndex.

Armin