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

Opening a web page by double clicking on a row in the Grid

sgobi
5-Regular Member

Opening a web page by double clicking on a row in the Grid

Hi
We have a requirement where the Users want to open a link (web page) by double clicking on a row in Gird.
They are passing a parameter(one column) from the row in the Grid.
Currently, I have a service to form the Source URL text on double click and I pass it to the Link widget to open it.
The Users still have to Click on the Link to view the new page.

Is there a way we can trigger the Link widget as soon as the Source URL text is formed?
Appreciate your help!

9 REPLIES 9

You can try using WebFrame instead of Link, but it will not open in new window. You will have to prepare space for it on your Mashup. 


Another idea that come to my mind is to change slightly 'Link' widget. You can copy this widget, and add your service ex. 'click', which you can than trigger with 'ServiceInvokeComplete' Event. 



sgobi
5-Regular Member
(To:sgobi)

Hi Mateusz
I want it open as a separate tab or Window.
Can you explain the second option?

Thanks
Sabarish



Go to Wiki and download "Creating UI Widgets for ThingWorx" document from section "09. ThingWorx Extensibility". 


There you can find details how widgets are built. 


To make your own AutoClickableLink widget you should copy link widget from __pathToTomcat__/webapp/Thingworx/Common/thingworx/widgets directory. Make structure of this files as described in 'Creating UI...' document and then edit sources. 


For example if you want to open/click link every time SourceURL changed it is as simple as change updateProperty function in ...link.runtime.js from: 


      this.updateProperty = function (updatePropertyInfo) {

          var domElementId = this.jqElementId;

          var widgetElement = this.jqElement;

          var widgetProperties = this.properties;

          var widgetReference = this;

  

          if (updatePropertyInfo.TargetProperty === 'SourceURL') {

              widgetReference.setProperty(updatePropertyInfo.TargetProperty, updatePropertyInfo.RawSinglePropertyValue);

              widgetElement.find('.widget-link').attr('href',updatePropertyInfo.RawSinglePropertyValue);

              return;

          } else if( updatePropertyInfo.TargetProperty === 'Text') {

              widgetReference.setProperty(updatePropertyInfo.TargetProperty, updatePropertyInfo.RawSinglePropertyValue);

            widgetElement.find('.widget-link').text(widgetReference.getProperty('Text'));

          }

      };

 

to


      this.updateProperty = function (updatePropertyInfo) {

          var domElementId = this.jqElementId;

          var widgetElement = this.jqElement;

          var widgetProperties = this.properties;

          var widgetReference = this;

  

          if (updatePropertyInfo.TargetProperty === 'SourceURL') {

              widgetReference.setProperty(updatePropertyInfo.TargetProperty, updatePropertyInfo.RawSinglePropertyValue);

              widgetElement.find('.widget-link').attr('href',updatePropertyInfo.RawSinglePropertyValue);

              widgetElement.find('.widget-link')[0].click();

              return;

          } else if( updatePropertyInfo.TargetProperty === 'Text') {

              widgetReference.setProperty(updatePropertyInfo.TargetProperty, updatePropertyInfo.RawSinglePropertyValue);

            widgetElement.find('.widget-link').text(widgetReference.getProperty('Text'));

          }

      };



As you can see, only part of the code I've changed is adding one line of code:

              widgetElement.find('.widget-link')[0].click();





paic
1-Newbie
(To:sgobi)

Just as another option, you can use an expression widget, so you can have your information go into an expression widget and trigger the evaluate from the double click on the Grid.

In the expression you would have: location.assign("Your URL Here") 
You will have to build that URL using some parameters.

squiroga
1-Newbie
(To:paic)

Hi Pai,

location.assign("Your URL Here")  where ? expression property ?

I was just trying to do the same thing and found this discussion.

Seems to be working exactly there, so Expression property in Expression widget.

This does open the link in the same tab, though. Not opening a new tab/window.

sgobi
5-Regular Member
(To:sgobi)

Hi Miikka,

How did you form your URL? Did you pass any value from the Grid to form the URL?

Appreciate if you send me the expression that you used.

qn
1-Newbie
1-Newbie
(To:sgobi)

I suppose a query is used to populate the Grid. You can bind the Query Selected Row / SourceURL to a Link widget. The Navigate service of the Link widget can be triggered by the Double clicked event of the Grid.

sgobi
5-Regular Member
(To:sgobi)

I am passing a value from the Grid column to another service which is used to form the URL. First, I need to trigger the service that forms the URL. Then I have to trigger the Link.

Announcements