SP.ListDataSource Class

Applies to: SharePoint Foundation 2010

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

SP.ListDataSource

Inherits

SP.ClientValueObject Class

Example

The following example creates an input button on an application page that shows which lists on the current website 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>

See Also

Reference

SP.ListDataSource Methods

SP.ListDataSource Properties

SP Namespace