Skip to main content
1-Visitor
Oct 24, 2014 7:33 PM UTC
Question

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

    1-Visitor
    Oct 27, 2014 12:43 PM UTC

    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. 



    Translate
    sgobi1-VisitorAuthor
    1-Visitor
    Oct 28, 2014 2:08 PM UTC

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

    Thanks
    Sabarish



    Translate
    1-Visitor
    Oct 29, 2014 8:23 AM UTC

    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();





    Translate
    1-Visitor
    Oct 29, 2014 12:04 PM UTC

    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.

    Translate
    1-Visitor
    Oct 7, 2015 3:20 PM UTC

    Hi Pai,

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

    Translate
    1-Visitor
    Oct 20, 2015 8:11 AM UTC

    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.

    Translate
    sgobi1-VisitorAuthor
    1-Visitor
    Feb 11, 2016 9:07 PM UTC

    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.

    Translate
    1-Visitor
    Feb 12, 2016 8:37 AM UTC

    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.

    Translate
    sgobi1-VisitorAuthor
    1-Visitor
    Feb 12, 2016 2:07 PM UTC

    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.

    Translate