cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Example of creating and populating an INFOTABLE in a client side widget

cdsouza
12-Amethyst

Example of creating and populating an INFOTABLE in a client side widget

I'm looking for an example of how to create and populate (LOCATION) entries in an INFOTABLE via the client-side widget (widget.runtime.js).

Thanks!

Cletus

ACCEPTED SOLUTION

Accepted Solutions
cdsouza
12-Amethyst
(To:cdsouza)

The following code snippet works for me.  Lines 1-16 create an infotable.  18-35 (really 27-32) populate the infotable with data.

var infoTable = new Object();

infoTable = {

    'dataShape': {

        fieldDefinitions: {},

        name: 'RegionLocations',

        description: 'Google Maps Region Locations'

        },

    'name': 'Region',

    'description': 'Google Maps Region',

    'rows': [{}]

};   

infoTable.dataShape.fieldDefinitions['Location'] = {

    name: 'Location',

    baseType: 'LOCATION'

};

for( var i = 0; i < latLngArray.length; i++ )

{

    var latLng = latLngArray;

    var newLocation = new Object();

    newLocation.latitude = latLng.lat();

    newLocation.longitude = latLng.lng();

    newLocation.elevation = 0;

    newLocation.units = 'WGS84';               

    var newRow = {};

    infoTable.rows.push(newRow);

    var row = infoTable.rows;

    newRow['Location'] = newLocation;

    infoTable.rows = newRow;

    delete row;

}

View solution in original post

1 REPLY 1
cdsouza
12-Amethyst
(To:cdsouza)

The following code snippet works for me.  Lines 1-16 create an infotable.  18-35 (really 27-32) populate the infotable with data.

var infoTable = new Object();

infoTable = {

    'dataShape': {

        fieldDefinitions: {},

        name: 'RegionLocations',

        description: 'Google Maps Region Locations'

        },

    'name': 'Region',

    'description': 'Google Maps Region',

    'rows': [{}]

};   

infoTable.dataShape.fieldDefinitions['Location'] = {

    name: 'Location',

    baseType: 'LOCATION'

};

for( var i = 0; i < latLngArray.length; i++ )

{

    var latLng = latLngArray;

    var newLocation = new Object();

    newLocation.latitude = latLng.lat();

    newLocation.longitude = latLng.lng();

    newLocation.elevation = 0;

    newLocation.units = 'WGS84';               

    var newRow = {};

    infoTable.rows.push(newRow);

    var row = infoTable.rows;

    newRow['Location'] = newLocation;

    infoTable.rows = newRow;

    delete row;

}

Announcements


Top Tags