Share via


SP.ListDataSource object

Represents information associated with a connection to an external data source.

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

var object = new SP.ListDataSource()

Members

The ListDataSource object has the following members.

Constructor

The ListDataSource object has the following constructor.

Constructor

Description

ListDataSource

Initializes a new instance of the SP.ListDataSource object.

Methods

The ListDataSource object has the following methods.

Method

Description

initPropertiesFromJson

writeToXml

Properties

The ListDataSource object has the following properties.

Property

Description

properties

Gets the properties associated with the connection to the data source.

typeId

This member is reserved for internal use and is not intended to be used directly from your code.

Example

The following example creates an input button on an application page that shows which lists on the current Web site are external.

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

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

    listCollection = site.get_lists();
    clientContext.load(listCollection, 'Include(Title,DataSource)');
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded() {
    var ds;
    var targetList;
    var messageExternal = "External Lists:";
    var messageNormal = "Normal Lists:";
    var listEnumerator = listCollection.getEnumerator();
    while (listEnumerator.moveNext()) {
        targetList = listEnumerator.get_current();
        // Get a ListDataSource object.
        ds = targetList.get_dataSource();
        if (!SP.ScriptUtility.isNullOrUndefined(ds)) {
            messageExternal += '\n\t' + targetList.get_title();
            // Get connection properties of the ListDataSource object.
            messageExternal += '(Entity=' + ds.get_properties()["Entity"] + ';  ';
            messageExternal += 'LOB System=' + ds.get_properties()["LobSystemInstance"] + ');  ';
        }
        else {
            messageNormal += "\n\t" + targetList.get_title();
        }
    }
    alert(messageExternal + "\n\n" + messageNormal);
}

function onQueryFailed(sender, args) {
    alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
}

</script>

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

</asp:Content>