spwrap.js – jquery plugin – SharePoint List Data with REST

, , Leave a comment

With this post, I am introducing spwrap.js

What is spwrap.js?

spwrap is a jquery plugin to make calls to multiple/single  SharePoint lists/list using REST

What all you can do with it ?

Call & Process from single or multiple SharePoint lists. You can also attach time interval i.e calling these calls after every N interval

How to use?

$("#elementId").spwrap({
             /*global events are called for each config data call*/
             globalEvents:
            {
                beforeRowAdd: null,
                afterRowAdd: null,
                onComplete: null
            },
             listConfigs: [
                 {
                     listName: 'SalesData',
                     fieldsToGet: [{ internalName: 'Title', displayName: 'Title' }
                     ],
                     timedUpdates: false, //get data for this config only once
                     beforeRowAdd: function(row){ //print this row  }
                },
                 {
                     listName: 'Tasks',
                     fieldsToGet: [{ internalName: 'Title', displayName: 'Title' }
                     ],
                     timedUpdates: true, //get update from the list 
                                        //every N interval configured in timerConfig
                     timerConfig:
                   {
                       interval: 1000,
                       storageType: 'localVariable',
                       fromCurrentTime: false
                   },
                     beforeRowAdd: function (row) {
                      $("#outPutDiv").append(row["Title"]);
                     }
                 }
             ]
         });

I have included vs solution with spwrap.js and a test page to showcase example use of the plugin (for the example to work, you will need to have ‘Tasks’ list). You can get the solution in download section by clicking ‘downloads’ link @ top of the page.

Hope you like the plugin
Note: I created the plugin just for fun. Feel free to modify or use it as you wish but at your own risk 🙂