NOTE: We've built a robust jQuery
library for SharePoint Web Services which provides easy access to the
SharePoint Web Services, like the UpdateListItems operation shown here.
It's available on Codeplex.
This page shows how you can use SharePoint's Lists Web Service and jQuery to
update items in real time, without a roundtrip to the server. It's based on a
great
blog post by Mike
Oryszak.
Because this demo uses Web Services, anonymous access will not work.
When you are prompted for credentials, use these:
Username:
demouser
Password: demouser
(As in "Demo User" -- nothing to do with rodents.)
Each row in the Data View Web part has buttons which allow you to
increase/decrease the Potential Value column by either $1 or $10. On each
button click, there is a SOAP call to the Lists Web Service (_vti_bin/Lists.asmx,
UpdateListItems operation) which updates the item. The jQuery code then
updates the value on the page and changes the fontStyle to italic.
After some DMs back and forth with Mike, at his suggestion (and for extra
fun), we used the Tablesorter 2.0 jQuery
library so that the table re-sorts after each Potential Value change.
A bonus effect of this is that the column headers are sortable as well.
The rudimentary styling on the headers shows this.
A known issue (which we chose not to deal with here) is that concurrent
changes will write over each other. There is no checking for these
conditions, though they could be managed fairly easily.
Make some changes to the amounts in the Potential Values column by clicking
the buttons (changed amounts will display in italics) and then refresh the page
to see that the changes have been saved.