on 07-07-2008 6:17 PM
Hi everyone.
How can I get the display text of the current selection in DropDownByKey field?
My selected key is a string but I could'n find the way of doing this.
Thanks a lot for your help,
Sara E.
Hi Gopi.
Thanks for your help, I did'n want to do a loop to find the value because I knew that in a field I have to have the value but I didn't know how to do that.
With Armin indications I did the following (I don't know if it is the best code, but I works):
MaktxKey is the selected key in the layout - Type string
ISimpleValueSet mmm = wdContext.currentContextElement().node().getNodeInfo().getAttribute("MaktxKey").getSimpleType().getSVServices().getValues();
mmm.getText(wdContext.currentContextElement().getMaktxKey()) -> It is a string with the display text of the current selection.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sara,
your code is ok but could be made slightly better (assuming that the context attribute "MaktxKey" has been created at design-time):
ISimpleValueSet values = wdContext.getNodeInfo().getAttribute(IContextElement.MAKTX_KEY)
.getSimpleType().getSVServices().getValues();
String text = values.getText(wdContext.currentContextElement().getMaktxKey());
Armin
Hi,
You can use the below sample code.
int iCountry =wdContext.nodeCountry().size();
String sCountryCode = null;
String sCountry = null;
String sCountryText = null;
// sCountry is the current country selected in the drop down.
sCountry = wdContext.currentEntry1DataElement().getCountryCode1();
for (int i = 0; i < iCountry; i++) {
sCountryCode =
String.valueOf(wdContext.nodeCountry().getCountryElementAt(i).getLand1());
sCountryText =
String.valueOf(wdContext.nodeCountry().getCountryElementAt(i).getLandx());
if (sCountry.equals(sCountryCode)) {
wdContext.currentEntry1DataElement().setCountryText1(sCountryText);
}
}
Thanks,
Gopi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The "selectedKey" property contains the key that you can use to get the "value" (text) from the associated value set. See
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.