11 Replies Latest reply on Jul 19, 2017 3:01 AM by tnayyar RSS
    tnayyar Creator

    Dynamic columns from Infotable

    Hi,

     

    I'm getting different Infotables with different count of columns. Say, table1 with 10 columns and table with 20 columns and these columns(names) are not fixed,may change frequently.

     

    Now I want to show all the columns from all the infotable onto a single GRID.

     

    In short,I don't have any predefined DataShape to bind.

     

    How to achieve that?

     

    I have tried below approach:

     

    ****************************************************

    // result: INFOTABLE dataShape: RootEntityList  //Fetching Thing Names on the basis of ThingShape Name

    var thingNames = ThingShapes[ThingShapeName].GetImplementingThings();

     


    //Creating Dynamic Infotable with no Datashape

    var params = {

    infoTableName: "MyTable" /* STRING */

    };

     

    //result: INFOTABLE

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

     

     

    //Looping to get thingName and get its Properties and adding its row in Dynamic Infotable,created above

    var tableLength = thingNames.rows.length;

    for (var y = 0; y < tableLength; y++)

    {

    var Tname = thingNames.rows[y].name;

     

        // result: INFOTABLE  

    var propertyValue = Things[Tname].GetPropertyValues();

     

     

       result.AddRow(propertyValue.rows[0]);

    }

    ****************************************************


    Output: Infotable without DataShape

    Mashup Bind: Grid bind to ALL DATA with "Show All Columns" option to "true".