1 Reply Latest reply on Jan 22, 2016 2:41 PM by cletusd RSS
    cletusd Newbie

    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

      • Re: Example of creating and populating an INFOTABLE in a client side widget
        cletusd Newbie

        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[i];
            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[i];
        
            newRow['Location'] = newLocation;
            infoTable.rows[i] = newRow;
        
            delete row;
        }