Skip to main content
1-Visitor
December 17, 2013
Question

Creating an InfoTable that contains one column of different InfoTable

  • December 17, 2013
  • 3 replies
  • 5840 views

How do I create a new InfoTable that contains just one column of a different InfoTable?

I thought it would be:

// Code to create newInfoTable based on a specific DataShape

newInfoTable = oldInfoTable.ColumnName;

But that doesn't seem to work.

Thanks

3 replies

1-Visitor
December 18, 2013

Hi Loren,

What is the need for the nested infotable? (Infotable inside another infotable)


To do this, you go through Snippets/InfoTable/Create New InfoTable from Datashape you get:


var params = {

infoTableName : "InfoTable",

dataShapeName : "NameOfYourDataShape"

};


// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(FeedData)

var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);


That is what you need to use to create your new InfoTable, the other part of course is to make sure you DataShape exists and has your Field(s) properly defined.



lorenmc1-VisitorAuthor
1-Visitor
December 18, 2013

Hi Pai,

I'm not trying to create a nested infotable.  I have an infotable with multiple rows and columns and I need to do some parsing of Text that is in one of the columns.  I initially thought of just creating a new infotable that contains a single column from the original infotable.  But all I really need to do is access the data in the particular column and then do so row by row, which I plan to do in a for loop.  However, I'm not sure of the JavaScript syntax to access a particular column of an infotable.  It seems like most of the code Snippets perform operations on an entire row.


If I use a getRow() method, what is the syntax to then access a particular cell or column of that row?


Thanks



1-Visitor
December 18, 2013

Hi Loren,

Depending on what you are going to do with the information, you probably will need to create an additional InfoTable to hold the resulting parsed information.

Anytime you loop through an InfoTable you indeed get the whole row.

I recommend you just use the:

for each (var entry in YourTableName.rows) {

}

So as this loops the variable entry will represent your row, and to get the values from a particular column then would become entry.NameOfTheColumn.


Hope that gets you on your way!



lorenmc1-VisitorAuthor
1-Visitor
December 18, 2013

Hi Pai,


In an attempt to implement your suggestion I created the following code to create a single column infotable.  However, when executed I am left with an empty infotable.  I know "iresult" contains the orignal infotable with all of the appropriate data since I can uncomment the last line and see the data when I execute the service.  Any idea what I'm doing wrong?


var params = {

nodeId: "204113" /* STRING */

};


// result: INFOTABLE dataShape: "OnRampSDUData"

var iresult = me.GetData(params);


var params = {

infoTableName : "InfoTable",

dataShapeName : "SensorDataShape"

};


//CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"),dataShapeName:STRING):INFOTABLE(SensorDataShape)


var tempresult = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);


for each (var entry in iresult.rows) {

    tempresult.AddRow(entry.sduHex);

}


result = tempresult;

// restul = iresult;



1-Visitor
February 12, 2014

can anyone please help no how to create infotable  within an info table, i need this to show Region in google map. To show Region/geoFence in goole map, it should have an infotable within info table, any help?



1-Visitor
February 12, 2014

Hi!


Infotables receive their table structure from DataShapes. So to create the table inside a table, you create your first datashape, then you create yet another datashape with one of it's field definitions to be of base type InfoTable with that first DataShape as it's datashape.

We also have a Regions example in the Support/Example section.