Get the displayed value of a valuelist in TYPEAHEAD field

Questions, tips and tricks and techniques for scripting in Servoy

Get the displayed value of a valuelist in TYPEAHEAD field

Postby Foobrother » Thu Jan 13, 2011 5:28 pm

Hi everybody,

I have a TYPEAHEAD field (which can be edited) with a valuelist using a relation when built. The dataprovider and displayed data are different. And I need to get the text displayed, especially when the dataprovider is null (no entry in database corresponding to text displayed).

I have not managed to find a function allowing to retrieve this displayed data for this specific case (dataprovider null, valuelist with relation and TYPEAHEAD field).

Any idea?

Cheers,
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: Get the displayed value of a valuelist in TYPEAHEAD fiel

Postby jcompagner » Fri Jan 14, 2011 11:13 am

do you have a null value mapping in that valuelist?
does application.getValueListDisplayValue(valueListName, realValue)

not work for you?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Get the displayed value of a valuelist in TYPEAHEAD fiel

Postby Foobrother » Fri Jan 14, 2011 12:13 pm

I don't really understand what you mean by null mapping.

Lets take an example.If in my database table I have:
Code: Select all
ID| Name
---------
1 | Mark
2 | John
3 |           //null mapping?
4 | Paul


Imagine the user enters in the field "Tom". How do you put this name into a variable? Obviously the dataprovider will have the value "null". But I want the name entered as mapping, not something predefined.
How can I save "Tom" in my table?

By the way, I have tried to set the field to type FIELD, as actually I don't need it to be TYPEAHEAD but the following code doesn't work either (but should according to the doc):
Code: Select all
elements.myField.getSelectedText()

It returns <null> when I select an element of the list.
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: Get the displayed value of a valuelist in TYPEAHEAD fiel

Postby jcompagner » Fri Jan 14, 2011 12:34 pm

what you want is not possible with a typeahead and a custom/table/related valuelist
Tom will not match and can't be saved.
With a name -> id valuelist it is mandatory that the display value is there in the target table.
Because we don't have any idea how to store that value.

Maybe you can some how solve this by using a global method valuelist..
Do remember what the user did type the last and if it didn't map on anything return a -1 or something.
then you can when he leaves the field look what the last value was and insert it and adjust the value.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Get the displayed value of a valuelist in TYPEAHEAD fiel

Postby Foobrother » Fri Jan 14, 2011 3:24 pm

Ok, I'm gonna try that then.

Do you have any idea why elements.myField.getSelectedText() is not working with FIELD?
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: Get the displayed value of a valuelist in TYPEAHEAD fiel

Postby jcompagner » Fri Jan 14, 2011 3:27 pm

are you sure that text is selected in the field? (this maps on text selection, doesnt have anything to do with a selection from a valuelist!)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Get the displayed value of a valuelist in TYPEAHEAD fiel

Postby Foobrother » Fri Jan 14, 2011 3:36 pm

I think it might be because when I type something new, it tries to find the corresponding ID but returns <null> and then when the DataChange is triggered and run elements.myField.getSelectedText() it tries to map <null> to a text from the valuelist and returns <null>?!

Because after the DataChange event (after I click away) the field becomes blank.

EDIT: Oooooooh, I just realised what this function is really doing! :lol:
Actually it's nothing to do with what I try to do. I though it was returning the text selected in the pull-down list! :oops:
Last edited by Foobrother on Fri Jan 14, 2011 3:42 pm, edited 1 time in total.
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm

Re: Get the displayed value of a valuelist in TYPEAHEAD fiel

Postby jcompagner » Fri Jan 14, 2011 3:41 pm

but you did do CTRL-A in the field? To select the text??

But yes this will not work if it can't map.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Get the displayed value of a valuelist in TYPEAHEAD fiel

Postby Foobrother » Fri Jan 14, 2011 3:44 pm

jcompagner wrote:but you did do CTRL-A in the field? To select the text??

But yes this will not work if it can't map.

No, I just realised what is really doing this function! (see my previous post) :lol:
I don't think this function can help as, I think, the text gets removed before the code of DataChange gets run :roll:
Current configuration: Servoy 5.2.6 Build 1011, Java 6u24, PostgreSQL 8.3, Windows Server 2003

Servoy / Java Developer
http://www.assetguardian.com
User avatar
Foobrother
 
Posts: 530
Joined: Tue Jan 13, 2009 5:46 pm


Return to Methods

Who is online

Users browsing this forum: No registered users and 14 guests