Friday, September 4, 2009

Enlarge input width size in edit/new pages

When editing list items in SharePoint, one of the most irritating issues I find is the width of the input fields, in particular the rich-text editor. So I have decided to fix this.




First of all we need to go to the page and set it in edit mode, which can be done by using the ToolPaneView=2 querystring. (See SharePoint Kings for more info), eg:

.....your-sharepoint-list-url..../EditForm.aspx?ToolPaneView=2

Then add a Content Editor WebPart. Make sure it is hidden in the appearance.
Finally add the following code:

<script type="text/javascript" src="{url-to-jquery}/jquery.js" language="javascript"></script> 


<script type="text/javascript">
function docready() {
  $('.ms-formbody').css('width', '100%');
  $('.ms-long').css('width', '100%');
  $('.ms-rtelong').css('width', '100%'); 
  $('.ms-rtelonger').css('width', '100%'); 
  $('#onetIDListForm').css('width', '100%');
}

_spBodyOnLoadFunctionNames.push("docready");

</script> 

Your forms will now use the complete width of your window.

Update: 25 september - Added the rte-longer class for also resizing the rich-text boxes

Future of navigation: Augmented Navigation



For more information about augmented reality, see this presentation

Tuesday, August 4, 2009

Function reference calculated fields in Sharepoint

Some times you need a list of functions you can use in Sharepoint calculated fields. It seems that this is available in your local machine...just go to: C:\Program Files\Microsoft Office\Office12\1033\STSLIST.CHM (if you got Office/Access 2007 installed)



or if you need an online version: wssdemo

or on your local sharepoint server:

http://server-name/_layouts/help.aspx?lcid=1033&cid0=MS.OSS.manifest&tid=MS.OSS.CH10176029&sq=calculated%20column


Show the year/week in Sharepoint

In order to group per week in a Sharepoint list, I have used the following function:

=IF([Completed date];YEAR([Completed date])&"/"&IF((INT(([Completed date]-DATE(YEAR([Completed date]);1;1)+(TEXT(WEEKDAY(DATE(YEAR([Completed date]);1;1));"d")))/7)+1)>10;INT(([Completed date]-DATE(YEAR([Completed date]);1;1)+(TEXT(WEEKDAY(DATE(YEAR([Completed date]);1;1));"d")))/7)+1;"0"&INT(([Completed date]-DATE(YEAR([Completed date]);1;1)+(TEXT(WEEKDAY(DATE(YEAR([Completed date]);1;1));"d")))/7)+1);"Uncompleted")

Actually the code to determine the weeknumber is:

=INT(([Completed date]-DATE(YEAR([Completed date]);1;1)+(TEXT(WEEKDAY(DATE(YEAR([Completed date]);1;1));"d")))/7)+1

So actually what I did was to first detect if the [Completed date] is valid (not empty), if it is it will show the text uncompleted. The next step was to check whether the week number is 2 digits if not then we will add an additional 0 to it, in order to make sure we can sort it correctly.

Modifying pages without the Edit page option in Sharepoint

Sometimes you want to customize a Sharepoint page, however the Edit Page item in the Site Actions Menu is not available. A good example for this is the Display and Edit page of a list item.

You can still do this by adding the ?ToolPaneView=2 parameter after the page url, eg. DispForm.aspx?ToolPaneView=2

Sunday, January 18, 2009

jQuery 1.3 issue - part 2

I have to apologize to the jQuery team, as it seems that jQuery does work. It seems there was a very strange issue with the Finjan software we are using at the office. When I downloaded jQuery at home, all seemed to be working.. after doing a file compare between what I got at the office and what I had downloaded at home, there was 1 line (the line I mentioned in previous post), different.

Anyway, this has been a lesson for me to double check the firewall and proxies..