List WebPart

The list webpart should be used when targeting a list as a datasource.

Configuration

The edit form includes a configurable web url textbox and list dropdown list. Additional form controls can be added to further customized.

Examples

Refer to the custom solutions for examples of creating custom webparts.

JavaScript
var WebParts = require("gd-sprest-bs").WebParts;

// Create the webpart
WebParts.WPList({
    elementId: "my-wpList",
    cfgElementId: "my-wpList-cfg",
    onRenderItems: function(wpInfo, items) {
        // Render the display element
        wpInfo.el.innerHTML = [
            '<h1>List: ' + wpInfo.ListName + '</h1>',
            '<h5>List Items: ' + items.length + '</h5>'
        ].join('\n');
    }
});
TypeScript
import { WebParts } from "gd-sprest-bs";

// Create the webpart
WebParts.WebPart({
    elementId: "my-wpList",
    cfgElementId: "my-wpList-cfg",
    onRenderItems: (wpInfo, items) => {
        // Render the display element
        wpInfo.el.innerHTML = [
            '<h1>List: ' + wpInfo.ListName + '</h1>',
            '<h5>List Items: ' + items.length + '</h5>'
        ].join('\n');
    }
});

Properties

Name Type Description
camlQuery string The caml query.
odataQuery Types.SP.ODataQuery The odata query.
onExecutingCAMLQuery (wpInfo: IListInfo, caml: string) => string The executing caml query event.
onExecutingODATAQuery (wpInfo: IListInfo, odata: Types.SP.ODataQuery) => Types.SP.ODataQuery The executing odata query event.
onRenderItems (wpInfo: IListInfo, items: Array<Types.SP.IListItemQueryResult | Types.SP.IListItemResult>) => void The on render items event.

Edit Form (IWPEditForm)

Name Type Description
listQuery Types.SP.ODataQuery The odata list query.
onListChanged (wpInfo: IListInfo, list?: Types.SP.IListQueryResult | Types.SP.IListResult) => Array<Components.IFormControlProps> | PromiseLike<Array<Components.IFormControlProps>> | void Event triggered when the selected list changes.
onListsLoaded (wpInfo: IListInfo, lists?: Array<Types.SP.IListQueryResult | Types.SP.IListResult>) => Array<Types.SP.IListQueryResult | Types.SP.IListResult> Event triggered when the lists are loaded.
onRenderForm (wpInfo: IListInfo, list?: Types.SP.IListQueryResult | Types.SP.IListResult) => Array<Components.IFormControlProps> | PromiseLike<Array<Components.IFormControlProps>> | void Event triggered when the form is being rendered.

WebPart Configuration (IWPCfg)

Name Type Description
ListName string The list name.
WebUrl string The relative web url.