9 Replies Latest reply on Feb 12, 2014 8:16 AM by paic RSS
    lorenmc Explorer

    Creating an InfoTable that contains one column of different InfoTable

    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



      • Creating an InfoTable that contains one column of different InfoTable
        paic Collaborator

        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.



        • Creating an InfoTable that contains one column of different InfoTable
          lorenmc Explorer

          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



            • Creating an InfoTable that contains one column of different InfoTable
              paic Collaborator

              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!



                • Creating an InfoTable that contains one column of different InfoTable
                  lorenmc Explorer

                  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;

                   



              • Creating an InfoTable that contains one column of different InfoTable
                abhishek Newbie

                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?