共用方式為


SP.FeatureCollection Class

Applies to: SharePoint Foundation 2010

Represents a collection of SP.Feature Class objects.

SP.FeatureCollection

Inherits

SP.ClientObjectCollection Class

Example

The following example creates an input button on an application page that uses the SP.FeatureCollection collection to display the identifiers (IDs) of the active features on the current website.

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">

    var featureCollection;
    var oneFeature;

    var site;
    function runCode() {
        var clientContext = new SP.ClientContext();
        site = clientContext.get_web();

        clientContext.load(site);

        featureCollection = site.get_features();
        clientContext.load(featureCollection);

        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    }

    function onQuerySucceeded() {
        var listEnumerator = featureCollection.getEnumerator();
        var featureInfo = '';

        while (listEnumerator.moveNext()) {
            oneFeature = listEnumerator.get_current();
            featureInfo += 'Feature ID: ' + oneFeature.get_definitionId() + '\n';
        }
        alert(featureInfo);
    }

    function onQueryFailed(sender, args) {

        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }

</script>

    <input id="Button1" type="button" value="Run Code" onclick="runCode()" />

</asp:Content>

See Also

Reference

SP.FeatureCollection Methods

SP.FeatureCollection Properties

SP Namespace