1,649 articles and 12,110 comments as of Wednesday, July 28th, 2010

Monday, October 5, 2009

Make SharePoint 2007 Act Like SharePoint 2010, Updated

Jan TielensGuest Author: Jan Tielens

In my previous post I introduced a small script to extend the Edit Control Block (ECB) of list items and documents. The added menu items in the ECB allow users to update certain metadata fields for that item or document.

The cool thing is that everything is happening in the background with the help of jQuery, even the actual updating of the data. The result: no postbacks or full page loads, pure AJAX goodness just like showcased in the SharePoint 2010 sneak peek videos. Today I’m releasing a new and improved version of the script, based on your feedback. Here are the changes:

Column names can have a display name and an internal name

In the previous version of the script you’d had to specify the names of the columns you’d like to ajaxify based on the internal name (which escapes spaces etc). In the new version of the script you can specify the display name as well. For example this is a possible configuration for a Task list:

columns: ["Status", "Priority", "% Complete#PercentComplete", "Description#Body"]

For the Status and Priority columns, no internal names are specified since they are the same as the display names. But notice that the next two columns have a # sign in them. The part preceding the # sign is the display name, the part after the # sign is the internal name from SharePoint.

Column values can have a display name and an internal name.

This works exactly as the column names, so if there is a # sign, the first part will be the display value, the second part will be the internal value. For example this is the array of values for the % Complete column of a task list:

["100%#1.00000000000000", "75%#0.750000000000000", "50%#0.500000000000000", "25%#0.250000000000000", "0%#0"]

Internally percentages are stored as values between 0 and 1. But we’d like show them as real percentages to the user of course: e.g. 100% will be displayed, while 1.00000000000 will be stored in SharePoint.

Multiple lists and document libraries can be configured in the same script.

Now you can also use the script if there is more than one list view web part on a page: in the lists option of the ajaxListConfig variable, multiple lists can be defined based on their name.

var ajaxListConfig = {
   lists:
   [
   { name: "Tasks",
   columns: [   ... ],
   values: [ ... ] },
   { name:   "Issues",
   columns: [ ... ],
   values: [ ...   ] },
   ],
   debug: 0, // set to 1 to see log messages
     animationSpeed: "fast" // possible values: "slow", "normal", "fast" or a number   (milliseconds)
  };

User entered values are now supported.

In the previous version, the user could only use the predefined values for a column (which makes lots of sense for Choice columns). In the new version, if the values option of a list configuration is equal to null (instead of an array of values), dialog is displayed in which the user can fill out a new value. For example in the Task list below, the Update Description menu item is displayed, but there is submenu to display the possible values.

SharePoint 2007 Act Like 2010 Update

When the user clicks on the Update Description menu item, a dialog is displayed to allow the user to modify the value. Once again there are no postbacks. To display the dialog I’m using the Imprompty jQuery extension (included in my script). Notice that there is no Rich Text editing (yet), so HTML tags will be stripped out. Also there is no support for editing Person fields etc.

SharePoint 2007 Act Like 2010 Update

Finally …

… some small bug fixes and performance enhancements are done. To use the script, configure it to your needs (when you download it, it’s configured for a default Task and Issue list), then follow these steps:

  1. Navigate to the page where you would like to use it (e.g. http://yoursite//Lists/Tasks/AllItems.aspx for the Task list).
  2. Click Site Actions, Edit Page (top right).
  3. Click Add a Web Part.
  4. Select the Content Editor Web Part in the Miscellaneous section and click Add.
  5. Optionally drag the Content Editor Web Part to the bottom of the screen (otherwise a small space will be displayed on top of the page).
  6. Click open the tool pane in the web part.
  7. Click Source Editor … in the properties task pane.
  8. Copy and paste the modified script in the Text Entry dialog and click Save.
  9. Click Exit Edit Mode (top right) and verify the result.

Let me know if you have any issues and/or any feature requests!

Download the script from Jan’s original article

Jan TielensGuest Author: Jan Tielens

Jan Tielens is .NET Architect and Trainer at U2U (http://www.u2u.be). He focuses on Information Worker technologies including SharePoint and Office.

Jan is Microsoft Most Valuable Professional (MVP) for Office SharePoint Server and he is well known in the SharePoint community as the author of the SmartPart. You can read his weblog at http://weblogs.asp.net/jan and follow him via twitter at http://twitter.com/jantielens.

View all entries in this series: JanTielens - SP 2007-2010»
Entries in this series:
  1. Make SharePoint 2007 Act Like SharePoint 2010 (sort of ...)
  2. Make SharePoint 2007 Act Like SharePoint 2010, Updated
 

Please Join the Discussion

3 Responses to “Make SharePoint 2007 Act Like SharePoint 2010, Updated”
  1. Man, this is a must-follow series! Keep it up!

  2. Magnus Timner says:

    I Jan,
    Thanks for a great script!

    I implemented it on a customized list I have and it works great, I change a Status field and it refreshes in the list.
    The thing that doesn’t work for med is when I implement it on another page with several views. I do the right click and the update status but I have to refresh the list myself to make it show in the list. Do you have any suggestions?

    Regards Magnus

  3. Vaishnavi Desai says:

    Hi Jan,

    Nice post. I found it very useful.

    I am trying to write a script or WF for a choice field in sharepoint form.
    The choice field also includes “Specify your own value” textbox.
    My goal is to allow user to enter value in that textbox and then update the choice list to include that value.

    Please let me know if you have any suggestions.

    Thank You.


Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!