SpRestLib

SpRestLib

  • Download
  • Get Started
  • API Documentation
  • SharePoint Guides
  • GitHub

›SpRestLib UI

Get Started

  • Installation
  • Promise You Will Love It
  • Promise-based Operations

Features

  • Library Integration
  • Library Options
  • SharePoint via Node.js
  • Utility Methods

API Reference

  • List/Library Methods (SP.List)
  • File Methods (SP.File)
  • Folder Methods (SP.Folder)
  • Site Methods (SP.Web)
  • User Methods (SP.User)
  • REST API Methods

SpRestLib UI

  • Form Binding

Help / Support

  • SharePoint Authentication

Form Binding

Include the optional sprestlib-ui.js library to perform control/form binding with an AngluarJS-like syntax made especially for SharePoint Web Services.

Many different HTML tags can be populated by adding an data-sprlib property to many HTML element types.

Installation

CDN

<script src="https://cdn.jsdelivr.net/gh/gitbrent/SpRestLib@1.8.0/dist/sprestlib-ui.min.js"></script>
// Use bundle for IE11 support
<script src="https://cdn.jsdelivr.net/gh/gitbrent/SpRestLib@1.8.0/dist/sprestlib-ui.bundle.js"></script>

Download

<script src="/subsite/SiteAssets/js/sprestlib-ui.min.js"></script>
// Use bundle for IE11 support
<script src="/subsite/SiteAssets/js/sprestlib-ui.bundle.js"></script>

Syntax

<tag data-sprlib='{ options }'>

Supported HTML Tags

The following HTML element tags can be populated:

  • select: select can be populated with various text/value options
  • table: table or tbody can be populated with 1-n SharePoint List columns
  • other: (input, p, span, etc.): populates a single, plain text value

HTML Tag Properties

NameTypeDescriptionPossible Values
liststringREQUIRED list/library nameEx:"list": "Employees"
colsarraycolumns to be selectedEx:"cols": ["ID","Title"]
filterstringquery filter valueEx:"filter": {"col":"ID", "op":"eq", "val":"99"}
limitintegermax items to returnEx:"limit": 100
optionsstringtable/tbody options(see below)
showBusybooleanshow busy animation during load(shows CSS animation before control loads)
  • cols is an array of either strings (Ex: cols: ["ID","Title"]), objects (Ex: cols: [{"name":"Title"}]) or a combination of the two (see Options below)

HTML Tag Properties: Table

NameTypeDescriptionPossible Values
tablesorterstringadd jQuery TableSorter plugin(only for tables). Adds the jQuery tableSorter library to table

HTML Tag Properties: Select

NameTypeDescriptionPossible Values
textstringtext string to show(only for select). Ex:text:"Title"
valuestringvalue string to show(only for select). Ex:value:"ID"

HTML Tag Properties: Cols Options

NameTypeDescriptionPossible Values
namestringthe OData column nameExamples: "Title", "Hire_x0020_Date", "AssignedTo/Email"
classstringCSS class name to useEx:"class":"highlight"
formatstringdate format optionAny of: US,DATE,INTL,INTLTIME,ISO. Ex:format: "INTL"
labelstringtext for table header(only for table tags without thead) show "Hire Date" instead of "Hire_x0020_Date", etc.
stylestringCSS style to useEx:"style":"width:50%; color:red;"

Examples

<!-- table/tbody -->
<table data-sprlib='{ "list":"Employees", "cols":["Name"], "filter":{"col":"Active", "op":"eq", "val":true}} }'>
<table data-sprlib='{ "list":"Employees", "cols":["Name",{"name":"Utilization_x0020_Pct","label":"Util%"}] } }'></tbody>
<tbody data-sprlib='{
    "list": "Departments",
    "cols": ["Title",{"name":"Modified","format":"INTLTIME"}],
    "limit": 10 }\'>
</table>

<!-- select -->
<select
    data-sprlib='{ "list":"Employees", "value":"Id", "text":"Name", "showBusy":true }'>
</select>

<!-- input -->
<input type="text" data-sprlib='{ "list":"Departments", "value":"Title" }' placeholder="Departments.Title"></input>

<!-- static elements span, div, etc. -->
<span data-sprlib='{ "list":"Employees", "value":"Name", "filter":{"col":"Name", "op":"eq", "val":"Brent Ely"} }'></span>
← REST API MethodsSharePoint Authentication →
  • Installation
    • CDN
    • Download
  • Syntax
  • Supported HTML Tags
  • HTML Tag Properties
    • HTML Tag Properties: Table
    • HTML Tag Properties: Select
    • HTML Tag Properties: Cols Options
  • Examples
SpRestLib
Docs
Getting Started with SpRestLibSharePoint API ReferenceSharePoint Development GuidesAbout JavaScript Promises
Community
FacebookTwitterPinterestYouTube Channel
More
GitHub IssuesGitHub ProjectSpRestLib on Stack OverflowSite Icons
Copyright © 2019 Brent Ely