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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Access elements (textbox,textarea) inside javascript function programmatically

Ashikkasim
5-Regular Member

Access elements (textbox,textarea) inside javascript function programmatically

i am in a situation where i use 40 to 50 fields (textbox,label) in a single mashup, currently for showing values in that fields i use the same 40 to 50 service, each for fields.This huge amount of services results in a slow page with massive lags. So am searching for a way - 

   there we can programmatically access all the fields(40 to 50 counts) in a single javascript service and manipulate it there itself, setting or getting text values of the fields like we do in native javascript(eg: that_specific_label.gettext())

7 REPLIES 7

Hi @Ashikkasim,

I'm not sure, having 40-50 Server calls is the right way to go.

I'm not sure how you can interact with the widgets js code directly from the mashup, but even if you did you will still call 40-50 server calls...

 

My suggestion is to create a single/few Services that will create an InfoTable result with a data shape of your texts and labels.

Then you should bind the results of the info table data to the widgets. 

 

Another way to do some frontend manipulation is by using expressions or even create your own widget.

 

Thanks,

Avihu.

abarki
15-Moonstone
(To:ashaban)

Hello Ashikkasim,

If @ashaban response has answered your question, please mark it as an Accepted Solution for the benefit of others who may have the same question in the future.

Thank you, and thank you for your contributions to the PTC Community.

abarki

Ashikkasim
5-Regular Member
(To:ashaban)

I partially accept your way but since there are other functionalities where I do some logics inside the code. I want to get/set the values of fields from javascript service programmatically.

Hello,

 

I agree with @ashaban answer that you should do a single REST call returning an INFOTABLE with all those 40 -- 50 values at once.

 

After that, if you need some post-processing on the client side, you can achieve it via Expressions in your mashup, which allow you to define some processing logic in JavaScript.

 

Regards,
Constantine

Ashikkasim
5-Regular Member
(To:Constantine)

is it possible in Thingworx to dynamically change values of fields programmatically without the binding?

AFAIK it can only be done via writing an extension.

 

There's another suggestion if you have a lot of values to display and need programmatic control for them -- you can put each of the 50 displayed properties as a row in an INFOTABLE (and execute this service once), then feed this INFOTABLE into a Repeater. You can implement your postprocessing and display logic inside contained mashup.

 

/ Constantine

You should use the Collection widget https://developer.thingworx.com/resources/guides/collection-widget-how-to, the repeat will be deprecated soon

 

Top Tags