Skip to main content
1-Visitor
February 22, 2021
Solved

Update the data of grid on addition of any new row without using auto-refresh

  • February 22, 2021
  • 2 replies
  • 2564 views

Hi Team,

 

Suppose I have a grid widget with live data populating on it with some service.

 

What I want if any new row gets added to above data then my grid data gets refreshed immediately (i.e. the service populating data gets called on addition of any new row event) without using auto-refresh. Also don't want to reload the entire page.

 

Please provide some logic so that this functionality can be achieved.

 

Thanks in advance.

Best answer by nmilleson

I've done this a couple of ways.  One, is to create a numeric Global Session Parameter and use the Resources["CurrentSessionInfo"].SetGlobalSessionNumberValue(params) snippet to set it to a random value every time you add rows to your infotable.  In your mashup, just grab the 'changed' event of that session param and tie it to the service that retrieves your data.  

 

Another way, is if the infotable is a property on a Thing (or you can use the same random method as above), you can select the 'Automatically update values when able' checkbox when you use the GetProperties service in a mashup.  Instead of having to pull the property values every time, it will automatically push them to your mashup without having to do a refresh.

 

Hope that helps!

2 replies

nmilleson17-PeridotAnswer
17-Peridot
February 22, 2021

I've done this a couple of ways.  One, is to create a numeric Global Session Parameter and use the Resources["CurrentSessionInfo"].SetGlobalSessionNumberValue(params) snippet to set it to a random value every time you add rows to your infotable.  In your mashup, just grab the 'changed' event of that session param and tie it to the service that retrieves your data.  

 

Another way, is if the infotable is a property on a Thing (or you can use the same random method as above), you can select the 'Automatically update values when able' checkbox when you use the GetProperties service in a mashup.  Instead of having to pull the property values every time, it will automatically push them to your mashup without having to do a refresh.

 

Hope that helps!

ranjank1-VisitorAuthor
1-Visitor
February 22, 2021

@nmilleson 

 

Could you please let me know how to set Global session parameters in ThingWorx.

 

Also if you can share the logic of method1 then it would be great.

17-Peridot
February 22, 2021

@ranjank ,

 

To create a session variable, navigate to the GlobalSessionProperties ThingShape and create a property in there.  

 

Then in your service where you're adding rows to your infotable/stream/datatable, just add this code right after you add the row:

 

var params = {
	name: "myNewSessionProperty" /* STRING */,
	value: Math.random() /* NUMBER */
};

// no return
Resources["CurrentSessionInfo"].SetGlobalSessionNumberValue(params);

 

In your mashup builder, click on Session and find the myNewSessionPropertyChanged event, and tie that to the service that returns your infotable.

Support
February 25, 2021

Hi @ranjank.

 

If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon