Make SharePoint 2007 Act Like SharePoint 2010, Updated
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.
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.
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:
- Navigate to the page where you would like to use it (e.g. http://yoursite//Lists/Tasks/AllItems.aspx for the Task list).
- Click Site Actions, Edit Page (top right).
- Click Add a Web Part.
- Select the Content Editor Web Part in the Miscellaneous section and click Add.
- 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).
- Click open the tool pane in the web part.
- Click Source Editor ... in the properties task pane.
- Copy and paste the modified script in the Text Entry dialog and click Save.
- Click Exit Edit Mode (top right) and verify the result.