Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hello Everyone,
I have created a Thing with 3 properties each taking InfoTable as Base Type. I have a Datashape with fields Timefield and Valuefield. I am able to display the infotable values in the chart.
What I want to achieve is, I need to display the infotable values in a GridTable below the chart widget as an explanation of what is depicted in chart. (Attaching the sample image with this)
But when I am trying to bind the 'GetPropertyValues' service, I am getting a nested infotable with Grid entry as [object Object].
How can I add each individual entries into Grid widget from infotable?
Please help me with a solution. Thank you.
Regards,
Airin
Solved! Go to Solution.
Hi Airin, Here is a way in which you can achieve your desired functionality. Create a Datashape with three properties of base type "String". Each property in this Datashape is used to withhold the TimeField and ValueField data from FaultTime, ProductCount and WaitingTime respectively. Create a service, under the Thing where you have defined the three properties of base type Infotable, as follows:
var params = { infoTableName : "InfoTable", dataShapeName : "GridDataShape" }; //GridDataShape is the DataShape with three properties of base type string var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params); var newEntry = new Object(); var tableLength = me.FaultTime.rows.length; var fualtTime; var productCount; var waitingTime; for (var x=0; x < tableLength; x++) { var row = me.FaultTime.rows[x]; //Your code here faultTime = "Time: " + row.TimeField + ", Value: " + row.ValueField; row = me.ProductCount.rows[x]; productCount = "Time: " + row.TimeField + ", Value: " + row.ValueField; row = me.WaitingTime.rows[x]; waitingTime = "Time: " + row.TimeField + ", Value: " + row.ValueField; newEntry.FualtTime = faultTime; // INFOTABLE newEntry.ProductCount = productCount; // INFOTABLE newEntry.WaitingTime = waitingTime; // INFOTABLE result.AddRow(newEntry); }
The output of the service should be of Type InfoTable with the Datashape created above. Bind the result of this service on the MashUp to the Grid widget to view the data.
Hi Airin, Here is a way in which you can achieve your desired functionality. Create a Datashape with three properties of base type "String". Each property in this Datashape is used to withhold the TimeField and ValueField data from FaultTime, ProductCount and WaitingTime respectively. Create a service, under the Thing where you have defined the three properties of base type Infotable, as follows:
var params = { infoTableName : "InfoTable", dataShapeName : "GridDataShape" }; //GridDataShape is the DataShape with three properties of base type string var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params); var newEntry = new Object(); var tableLength = me.FaultTime.rows.length; var fualtTime; var productCount; var waitingTime; for (var x=0; x < tableLength; x++) { var row = me.FaultTime.rows[x]; //Your code here faultTime = "Time: " + row.TimeField + ", Value: " + row.ValueField; row = me.ProductCount.rows[x]; productCount = "Time: " + row.TimeField + ", Value: " + row.ValueField; row = me.WaitingTime.rows[x]; waitingTime = "Time: " + row.TimeField + ", Value: " + row.ValueField; newEntry.FualtTime = faultTime; // INFOTABLE newEntry.ProductCount = productCount; // INFOTABLE newEntry.WaitingTime = waitingTime; // INFOTABLE result.AddRow(newEntry); }
The output of the service should be of Type InfoTable with the Datashape created above. Bind the result of this service on the MashUp to the Grid widget to view the data.
I think you can do it by using the GetProperties service instead of GetPropertyValues
Thank you @Rajesh_Sayana and @PaiChung for the quick response.
I tried both the solutions.
@PaiChung ,For 'GetProperties' service, we couldn't get all the properties together in a single grid widget. Instead when I tried 3 grids with each bound with GetProperties service, it worked.
@Rajesh_Sayana Thank you for the detailed explanation. I tried your code snippet; but I was getting TypeError (rows undefined, length undefined). Why is it so?
Hi Airin, I would like to know if your are creating the service under the Thing where you have three properties defined of base type Infotable. "me" in the service here is supposed to represent the Thing entity that has these three InfoTable properties you have defined. If you have defined the FaultTime as Infotable basetype, then it should not throw the error you have mentioned. Please double that and let me know if that helps.
Yes @Rajesh_Sayana , I done exactly the same way as you said.
Attaching the screenshot showing the Thing and its properties.
The datashape 'Brindavan_DataShape' has field definitions as 'ProductCount', 'WaitingTime' and 'FaultTime' with String as base type.
Also, it will be grateful if you can help me with the usage of set operations (intersect/union) with a code snippet.
Thank you in advance.
Best Regards,
Airin
I think this can solve my issue