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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Click event in list widget activates hyperlink

Tlshevel
5-Regular Member

Click event in list widget activates hyperlink

Hello,

I'm trying to create a dynamic list. So that when an item in the list is clicked on, it sends me to another experience (i.e. activate a hyperlink) 


I'm currently populating the list with a JSON list and utilizing the "return JSON.parse(value)" function, and the list displays the Name column.
[{"Experience":"URL1","Name":"Name1"},{"Experience":"URL2","Name":"Name2"},{"Experience":"URL3","Name":"Name3"},{"Experience":"URL4","Name":"Name4"}]

 

So the question is, how do you go about utilizing the "Item click" event within the list widget to activate a hyperlink based on which item was clicked?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

You can do this without the use of the hyperlink widget. Add this function to your Home.js file and then call it on the 'Item Click' event of the list widget.

 

$scope.openExperience = function(){
  
  var list = $scope.app.view['Home'].wdg['list-1']['list'];
  var selection = $scope.app.view['Home'].wdg['list-1'].list.selectedRows;
  
  for(i=0; i<list.length; i++)
  {
    if(list[i].Experience == selection[0].Experience)
    {
      window.location = list[i].Experience;
    }
  }
}

View solution in original post

1 REPLY 1

You can do this without the use of the hyperlink widget. Add this function to your Home.js file and then call it on the 'Item Click' event of the list widget.

 

$scope.openExperience = function(){
  
  var list = $scope.app.view['Home'].wdg['list-1']['list'];
  var selection = $scope.app.view['Home'].wdg['list-1'].list.selectedRows;
  
  for(i=0; i<list.length; i++)
  {
    if(list[i].Experience == selection[0].Experience)
    {
      window.location = list[i].Experience;
    }
  }
}
Top Tags