Back about four years ago while working at a customer gig, I created a client side Java Script library which uses AJAX to talk to lists.asmx for things like retrieving list items, edit, update and delete. Basically client hated the post back model with SharePoint back in older version, we couldn’t deploy custom code due to governance related constraints on deploying custom code to the environment so client side programming was the only thing we could do. Without going into too much details with few references to some script files and some initialization code in a content editor web part is all you need.
You can assemble dashboard like page which allowed site users to perform crud like operations on bunch of lists all in single page without many post backs.
Now you might be wondering why I’m bringing this up now, since everything is moving towards Office 365 and you want to improve user experience especially when users perform CRUD like operations on many lists and constraints like the one we faced back in the day around deploying custom code into Shared environment kind of applies. There is two things I want to achieve with this post
- One introduce you guys to this library, basically no code has changed since I wrote it four years ago. I want to refactor this code to leverage java script client object model where ever I can as well as use Marc Anderson’s SPServices instead of my little java script wrapper for Lists.asmx web service, I also want to leverage jQuery, but I’m only going to do it if you guys think it’s useful, so I would greatly appreciate if you respond via comment and let me know
- Secondly I want to show you guys the functionality working in a live environment, head over to this link http://www.spmcm.me/demo
In the demo site link provided above I configured this with “Tasks” list. Added a content query web part to the landing page and added following in the content editor web part.
Script above is pretty straightforward and not much to explain “DataBind” function in list view object will use AJAX to get list data and render it inside the “div” element defined. Obviously there is lot of implementation details that I can’t go through in a post
Here is what it looks like when its retrieving list items
Image below shows view after retrieving list items using AJAX and rendering on the client. All changes made in the list view are saved locally in cache and only when you click on “update” it sends those changes to server
Here is how it looks when you insert a new row into the list view
And image below shows when you edit an existing row
Image below shows after a validation error occurred when committing changes
That’s it, I’m looking forward to hearing from you guys