ShapeDataItemCollection object (JavaScript API for Visio)

Applies to: Visio Online

Represents the ShapeDataItemCollection for a given Shape.

Properties

Property Type Description
items ShapeDataItem[] A collection of shapeDataItem objects. Read-only.

See property access examples.

Relationships

None

Methods

Method Return Type Description
getCount() int Gets the number of Shape Data Items.
getItem(key: string) ShapeDataItem Gets the ShapeDataItem using its name.
load(param: object) void Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

Method Details

getCount()

Gets the number of Shape Data Items.

Syntax

shapeDataItemCollectionObject.getCount();

Parameters

None

Returns

int

getItem(key: string)

Gets the ShapeDataItem using its name.

Syntax

shapeDataItemCollectionObject.getItem(key);

Parameters

Parameter Type Description  
key string Key is the name of the ShapeDataItem to be retrieved.  

Returns

ShapeDataItem

load(param: object)

Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

Syntax

object.load(param);

Parameters

Parameter Type Description  
param object Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object.  

Returns

void

Property access examples

Visio.run(function (ctx) { 
    var activePage = ctx.document.getActivePage();
    var shape = activePage.shapes.getItem(0);
        var shapeDataItems = shape.shapeDataItems;
        shapeDataItems.load();
        return ctx.sync().then(function() {
            for (var i = 0; i < shapeDataItems.items.length; i++)
            {
                console.log(shapeDataItems.items[i].label);
                console.log(shapeDataItems.items[i].value);
            }
        });
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});
="property-access-examples">Property access examples
Visio.run(function (ctx) { 
    var activePage = ctx.document.getActivePage();
    var shape = activePage.shapes.getItem(0);
        var shapeDataItems = shape.shapeDataItems;
        shapeDataItems.load();
        return ctx.sync().then(function() {
            for (var i = 0; i < shapeDataItems.items.length; i++)
            {
                console.log(shapeDataItems.items[i].label);
                console.log(shapeDataItems.items[i].value);
            }
        });
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});