Sometime you need to a have a link to filtered list in Sharepoint. Luckily Sharepoint has the ability to do this. You need to use the following parameters after the list url:
......allitems.aspx?Filtername=<name of field>&FilterMultiValue=<filter text>
<name of the field> is the field name in your list, you wish to filter on (eg. Name etc)
<filter text> is the filter criteria. You can use * as an wildcard. You can add multiple filter text values by separating them with semi colons.
For example:
......allitems.aspx?Filtername=Name&FilterMultiValue=A*;B*
will show all items starting where the Name starts with A or B.
I like this method because it allows you to have multiple values and wildcards. You could also use the FilterField1 and FilterValue1 parameters. (see for more info: Using URL to sort or filter a list).
Random thoughts about programming for the web. Sometimes it will make sense, probably most of the time, it will not make sense.
Showing posts with label sharepoint. Show all posts
Showing posts with label sharepoint. Show all posts
Tuesday, January 26, 2010
Tuesday, December 15, 2009
Merging items with same title in gantt view in Sharepoint
Today, got a challenge with Sharepoint where a user wanted to see multiple entries in a gannt view in Sharepoint. Below is the jquery magic you can use in a CEWP.
Explanation of the code:
function docready() { var row = []; var ix=0; $('tr.ms-ganttTaskRow th').each( function() { row[ix] = $(this).parent(); ix++; } ); ix=0; for(ix=1; ix< row.length; ix++){ var $prevrow = row[ix].prev(); var prevtxt = $prevrow.find('th').text(); var curtxt = row[ix].find('th').text(); if (prevtxt == curtxt) { var colix =0; row[ix].find('td').each( function() { var ht = $(this).html(); if (ht.length > 0){ $prevrow.find('td:eq('+colix+')').html(ht); } colix++; } ); row[ix].remove(); } } } _spBodyOnLoadFunctionNames.push("docready");
Explanation of the code:
- Trigger the docready on load
- Store all the rows in an jquery array for easy processing
- Walk through the rows array starting from second item and match the row header with previous row, if so, copy the contents of the columns to the row above and remove after processed.
Friday, October 16, 2009
Maintenance of Sharepoint Web Parts
For some reason, all the web parts ever added to a page in Sharepoint are actually never really removed when you delete them from the page. You can see this for example when you edit the page in Sharepoint Designer. Actually it is a good feature which allows you to retrieve webparts which could have been accidently removed by a user.
You can also remove or clean up the not used web parts in a page by using the Web Part Maintenance page.
It also allows you to remove buggy web parts which prevent your page to load.
You can access this maintenance page by going to the following page:
http(s)://[site-collection-root]/_layouts/spcontnt.aspx?url=[relative path to the page]
You can also remove or clean up the not used web parts in a page by using the Web Part Maintenance page.
It also allows you to remove buggy web parts which prevent your page to load.
You can access this maintenance page by going to the following page:
http(s)://[site-collection-root]/_layouts/spcontnt.aspx?url=[relative path to the page]
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:
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
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
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
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.
=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
You can still do this by adding the ?ToolPaneView=2 parameter after the page url, eg. DispForm.aspx?ToolPaneView=2
Subscribe to:
Posts (Atom)