cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How can we add keypress event in our textbox i.e whenever a key is pressed in a textbox and a values is typed it should call a web service.

psaxena
1-Newbie

How can we add keypress event in our textbox i.e whenever a key is pressed in a textbox and a values is typed it should call a web service.

we have a text box in which we enter some text and then on changed event of text box a service is called which posts a json and returns the data corresponding to it.

Now we want when we type just one letter or 2 or 3 letters of that string it should call the web service and give the matching result. Basically we need keypress functionality  in textbox

1 ACCEPTED SOLUTION

Accepted Solutions
nkhose
1-Newbie
(To:psaxena)

1)Firstly you can bind your webservice's Thingworx Service result as "Data"  to the autocomplete widget as we do normally for grid widget .

2)Look for the event the autocomplete widget has "Textchanged" & "Textselected" event .Bind the Textchanged event to the same service in (1)

Configuration part :

You will see the fields of infotable  in Autocomplete widget binding left nav botton give name & display values .

Give minimum length of characters  in your case 2 chanracters to fire the service on "Textchanged" event . If you want to fire

any service on selection of textbox values you can bind "Textselected" event

Let me know if you got this or anything needed on this

View solution in original post

6 REPLIES 6
nkhose
1-Newbie
(To:psaxena)

I think with the existing textbox widget keypress event is not possible instead any out of box way to do it , however as you say

typing 2 or 3 characters webservice should call you should try the "Autocomplete Widget" from marketplace https://marketplace.thingworx.com/Items/autocomplete surely your requirements exactly match by using it .

psaxena
1-Newbie
(To:nkhose)

Hi Nilesh,

I downloaded the autocomplete widget,but I am not able to get that from where will the widget get suggestions when we type something in the box.I want that whatever I type should call the web service and the suggestions should be returned from the web service itself dynamically.

nkhose
1-Newbie
(To:psaxena)

1)Firstly you can bind your webservice's Thingworx Service result as "Data"  to the autocomplete widget as we do normally for grid widget .

2)Look for the event the autocomplete widget has "Textchanged" & "Textselected" event .Bind the Textchanged event to the same service in (1)

Configuration part :

You will see the fields of infotable  in Autocomplete widget binding left nav botton give name & display values .

Give minimum length of characters  in your case 2 chanracters to fire the service on "Textchanged" event . If you want to fire

any service on selection of textbox values you can bind "Textselected" event

Let me know if you got this or anything needed on this

psaxena
1-Newbie
(To:nkhose)

Hi Nilesh,

It worked as expected but there is one more constraint that I want to pass the changedText as an input parameter to my webservice and when i get the suggested result then on selecting one of them the details should be displayed in the grid and not of all suggestions(only the details of selected suggestion).

nkhose
1-Newbie
(To:psaxena)

In that case , Suppose you selected you the text result from the auto. widget bind "Selected Text" to any service which takes input  , and fire theTextSelected Event to the service which takes input and then bind specific service to Grid as "Data" .

Or Alternative way is bind the selected text to new textbox (make sure you make visible false when mashup is LIVE), and then bind the textbox changed event to the service that you want to bind to Grid

Hope this helps

psaxena
1-Newbie
(To:nkhose)

My service takes single the input and based on that only I am getting the suggestions. Now how can the same service take the SelectedText as input when it is taking ChangedText as input  which returns the suggestions.

Top Tags