SP へFieldCollection オブジェクト (sp.js)

の SP のコレクションを表しますフィールドオブジェクトです。

**適用対象:**apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

var object = new SP.FieldCollection()

メンバー

FieldCollectionオブジェクトでは、次のメンバーがあります。

Constructor

FieldCollectionオブジェクトでは、次のコンスがあります。

コンストラクター

説明

FieldCollection

Initializes a new instance of the SP.FieldCollection object.

メソッド

FieldCollectionオブジェクトでは、次の方法があります。

メソッド

説明

追加します。

Adds a field to the field collection.

addDependentLookup

Adds a secondary lookup field that depends on a primary lookup field for its relationship to the list where it gets its information.

addFieldAsXml

Creates a field based on the specified schema, Boolean value, and field options.

getById

Gets the field with the specified ID.

getByInternalNameOrTitle

Returns the first Field object with the specified internal name or title from the collection.

getByTitle

Returns the first field object in the collection based on the title of the specified field.

initPropertiesFromJson

itemAt

Gets the field at the specified index in the collection.

プロパティ

FieldCollectionオブジェクトでは、次のプロパティがあります。

プロパティ

説明

childItemType

アイテム

Gets the specified field from the collection.

schemaXml

Specifies the XML schema of the collection of fields.

次の例では、 FieldCollectionコレクションを使用して、お知らせリストで利用可能なフィールドを表示するアプリケーション ページの [入力] ボタンを作成します。

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

    var fieldCollection;

    function runCode() {
        var clientContext = new SP.ClientContext();
        var targetList = clientContext.get_web().get_lists().getByTitle('Announcements');
        fieldCollection = targetList.get_fields();
        clientContext.load(fieldCollection, 'Include(Title)');
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    }

    function onQuerySucceeded() {
        var message = "The following fields are available in the Announcements list:\n\n";
        var fields = '';
        var listEnumerator = fieldCollection.getEnumerator();
        while (listEnumerator.moveNext()) {
            fields += listEnumerator.get_current().get_title() + "; ";
        }
        alert(message + fields);
    }

    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>

他のリソースのエンドポイント

詳細については、 FieldCollection リソースを参照してください。

エンドポイント URI 構造

http://<sitecollection>/<site>/_api/web/lists(listid)/fields

HTTP 要求

このリソースには、次の HTTP コマンドがサポートしています。

書式を取得します。

GET http://<sitecollection>/<site>/_api/web/lists(listid)/fields

投稿の書式

POST http://<sitecollection>/<site>/_api/web/lists(listid)/fields