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

Get row-col value from dynamically populated grid widget and pass it as a input to another service?

EM_9923519
12-Amethyst

Get row-col value from dynamically populated grid widget and pass it as a input to another service?

 

I have an asset that has several properties (image1)

lastConnection

latestRegistrationDate

managedDevices   

etc....

 

 

managedDevices is a infotable containing several other values.

 

 

What I am doing is populating several labels and a grid within my mashup using a service (MyAsset is a parameter that allows me to dynamically load different assets):

 

var result = Things[MyAsset].GetPropertyValues();

 

 

So I have something like (image2)

 

This works, now I want to extract the selected row-col value from that grid and pass this value as a parameter to navigation input so I can navigate to other Mashup when I double click a row of the grid.

 

I have two columns in the grid (image3) 

name

looupId

 

I want to extract the lookupId value of the selected row

 

One idea I tried to implement was to call a service when double clicking the row (image4)

and after the service call ends I execute the navigation passing the parameter I need from the result of service call. But I had no success

 

 

 

I would expect to solve this setting the corresponding DataShape to the grid widget but I don't know how to do it, and also don't know if that will facilitate the binding the selected row-col value possibility

 

 

Could you please suggest how to solve this?

 

 

Anyone?

1 REPLY 1

Update:

I have tried several approaches but still no success, this is the closest way and I think I almost solve it:

 

I defined a one field datashape (image 1 )

q11.png

I am populating the grid using a direct service (not via the properties of the  script I shared)

instead of getting properties like:

var result = Things[MyAsset].GetPropertyValues();

 

I am using this:

//I tried this but datashape was not getting the values so I tried define a infotable without a data shape and force the datashape to be the one I defined

var managedDevices = Things[selectedThing].managedDevices;

 

var params = {
   infoTableName: undefined /* STRING */
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].CreateInfoTable(params);
result.AddField({name: "name", baseType: "STRING"});

var tableLength = managedDevices.rows.length;
for (var x=0; x < tableLength; x++) {
  var row = managedDevices.rows[x];
  // add data row
  result.AddRow({
      name : row.lookupId
   });
}

 

This returns an infotable with the correct datashape:

q11.png

So far so good:

I am binding Returned Data -> All data to my grid and this works fine

Problem comes when binding the Selected Rows-> name 

q12.png

I first tried to bind this to a label to see if I can extract the selected row value, but label does not change its value.

 

Then I thought the problem should occur because there is no event that updates the label value so I created a service that is called when double clicking

the row like:

 

var result = name;

q13.png

I am passing the parameter "name" from selected row service:

q14.png

 

Summary

 

When I click on a row from grid I call a service (the parameter comes from my populate grid service selected rows name field from datashape)

I am binding the result of this servide to label value to extract the grid column value, but I get undefined value

I don't know what I am doing wrong, I think I almost solve this...

 

Could you please help me?

 

 

 

I defined a Datashape with only one column 

Top Tags