Archive

Posts Tagged ‘MOSS SharePoint’

Reordering/Ranking SharePoint List Items

August 6, 2010 22 comments

SharePoint link list has a feature which lets you Re-Order list items and this is done using List Actions.

image

This in turn uses ReOrder.aspx page to reorder list items. Here is a summary how this functionality it implemented.

  • Links list contains a field called “Order” which is an internal field and default view is sorted by it.
  • Reorder.aspx uses this Order field to update and reorder list items in that view.
  • Default view is sorted by Order field and reflects the new order.

Now code that runs in Reorder page doesn’t really care about most list types and location since it uses list GUID to modify the order and the Order field is part of each and every list template but for some reason SharePoint has blocked this feature from all the other list templates, like most other things. But given the list GUID Reorder page is able to sort list items. So why doesn’t it work ?  Because Order field being an Internal field is also hidden from other list templates, so while it is possible to reorder we are unable to create a view which will use this order to sort list items.

There are tons of posts around this method and dropping in data view web part to sort list items and solutions which implement their own ordering feature. I prefer a much simpler approach (according to me at least) . Unhide the damn order field and create a view.

I have created a feature which does exactly that.

“List Order”  is feature which enables list re ordering for your custom list. The feature is enabled on “Web” level and enables this action item for all the lists for that particular site. The feature has 2 parts to it:

1. Custom List Action item:  This provides the action item to link to list –reorder page.

image

2. “By Order” View:  When feature is activated, it creates a view on the supported list called “By Order” which is sorted by the “Order” field. (Note: This is only applies to existing lists and wont reflect on  newly created list. however you can create your own views and select the sort by “order” field)

image

Now the feature once activates will provide the Action Item and View to all the supported list types for that particular site. I haven’t tested this feature with huge list or many other scenarios, but I assume it would work similarly to a link list and I don’t see a use case for manually reordering lists with more than 50 items in it.

Screenshots:

1. Reorder Action item on custom list:

image

2. “By Order” view before reordering of list items

image

3. Reorder page

image

4. “Order By” view after refresh

image

Note: It is currently configured to work with following list templates:

  1. Generic List
  2. Contacts List
  3. Task List
  4. Gantt List

You can change them if you like from the source code.

Downloads:

Feature WSP Download
Source code Download
Advertisements

Extending SPFF

August 7, 2009 1 comment

Paul Grenier has created a wonderful script SPFF for manipulating Sharepoint form fields from URL. I have used javascript for field data manipulations a lot and his script makes it a breeze to implement. The fact that he has covered various forms of OOB fields is by itself worth having this as part of your toolbox.

You can download and read (extensive) documentation from codeplex http://spff.codeplex.com/

Extending SPFF:

Why?

I like URL based field manipulation, but it is not always enough and why just stick to one point of entry. If you are an user using Javascript for form manipulation you already hands on and wouldnt mind going crazy with the whole implementation script based implementation.

What:

1. There is a fix which lets you hide and set values for the fields from URL.

2. Now you can call these operation from your own Javascript code.

Download It is still uploaded as a path and waiting for approval.

E.g:

Setting values based on Drop Down values. We will use OOB task list.

In this example when a user selects “Status” as completed it will automatically set the percentage field to “100%”

image

image

Steps:

1. Follow instruction on how to load this Javascript and adding Content Editor to New/ Edit Form pagefrom Pauls codeplex page.

2. In Content Editor Source Editor Add the code below

<script language="javascript" type="text/javascript">
 _spBodyOnLoadFunctionNames.push("modifyflds");

function modifyflds()
 {
 $("select[title^=Status]").bind("change",statusChange);

}

function statusChange()
 {
 var Selected =$("select[title^=Status]").val() ;
 if(Selected=="Completed")
 $.spff({field:'% Complete',value:'100',lock:true});

}
 </script>

In the code above we are adding an “on Change” event handler on “Status” field. In the function we check if the field is completed using SPFF we set % Complete to 100%