Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

QlikView Ajax API - How to select a specific text "value" in a list box?

Does anyone know how to select a specific text "value" using the QlikView Ajax API for a list box?  There is a "problem" that I am trying to work around and curious if anyone else has run into this or knows of a way to make the following scenario work.

Say you had a list box that contained the following values "Jerry Berry, Tom Ball, John Al, John Alfred, John Alverado".  Now say you want to use the QlikView Ajax API to only select the entry for "John Al".

When using the QlikView Ajax API's SelectTexts() method it will return a wildcard search instead of matching on the exact value.  In this scenario the API will select all the following values "John Al, John Alfred, and John Alverado".  My problem is that I only want "John Al" selected, not all the other names that start with John Al.

Does anyone know how to do this?

1 Solution

Accepted Solutions
Not applicable
Author

Found the answer thanks to Rob Wunderlich.

In the search string you can use an expression with the field name to make an exact text value selection.

For the list box in the example above you can do the following...

<head>

<script language="javascript">

     var userNameListBox= qva.GetQvObject("LB01", function () {

     });

     function selectUser() {

          // the name of the field associated with the list box.

          var fieldName = "UserName";

          // where to get the name of the user to select.

          var userName = document.getElementById("userNameInput").value;    

          // create the search string for qlikview to select.

          // the expression should look like this "=[UserName] = 'John Al'"

          // use "=" to indicate the search string is an expression

          // use ' single qoutes to wrap the value

          // if you want select multiple values you can use an "OR" like so "=[UserName] = 'John Al' or [UserName] = ''John Ala"

          var values = ["=[fieldName] = '" + userName + "' "];

          // qlikview ajax api to do the select text.

          userNameListBox.QvaPublic.Data.SelectTexts(values);

     }

</script>

<body>

<input id='userNameInput' type='text' value='John Al'/>

<input id='selectButton' type='button' value='select' onclick='selectUser();'/>

</body>

View solution in original post

2 Replies
Not applicable
Author

Found the answer thanks to Rob Wunderlich.

In the search string you can use an expression with the field name to make an exact text value selection.

For the list box in the example above you can do the following...

<head>

<script language="javascript">

     var userNameListBox= qva.GetQvObject("LB01", function () {

     });

     function selectUser() {

          // the name of the field associated with the list box.

          var fieldName = "UserName";

          // where to get the name of the user to select.

          var userName = document.getElementById("userNameInput").value;    

          // create the search string for qlikview to select.

          // the expression should look like this "=[UserName] = 'John Al'"

          // use "=" to indicate the search string is an expression

          // use ' single qoutes to wrap the value

          // if you want select multiple values you can use an "OR" like so "=[UserName] = 'John Al' or [UserName] = ''John Ala"

          var values = ["=[fieldName] = '" + userName + "' "];

          // qlikview ajax api to do the select text.

          userNameListBox.QvaPublic.Data.SelectTexts(values);

     }

</script>

<body>

<input id='userNameInput' type='text' value='John Al'/>

<input id='selectButton' type='button' value='select' onclick='selectUser();'/>

</body>

Not applicable
Author

Hi Julius,

i don't have understand where is the file html where i must write the code...

Someone can help me?

Thank's