Monthly Archives: May 2014

Cleaner List View Boxed style using jQuery

I’m sure we’ve all customized Lists in SharePoint to create different types of views. While most of the Styles to choose from aren’t always practical, the Boxed view is an interesting view because it creates a Table along with a row of all your properties and values, for each List item. A common issue with this view is that if you have empty values, it takes up space on the screen and is too “ugly” to use. This is particularly true if your list or library is associated with many Content Types because different Content Types may not populate certain fields. There’s also that hideous column/filter bar that doesn’t seem to have any value on a view like this.

By adding the jQuery below, you can make the Boxed view much more presentable. It will not display columns that have empty values or unchecked (yes/no) values.

$(“table.ms-listviewtable tr td.ms-stylebox table tr”).each(function() {
var [...]

By |May 20th, 2014|Uncategorized|13 Comments|

Accounting for Site / Subsite regional time zone settings

Often times, you will have custom web parts or code that write date values back to lists. In many cases, time zone settings are different across an organization and using DateTime.Now is generally not recommended.

Two scenarios come to mind. #1, when a site changes its time zone to be different than the hosted servers’ time zone. #2,  if a web part was deployed across a Site Collection and used in 5 different sub-sites with 5 different regional time zone settings.

I found the best way to retrieve a date is this here:

// time zone of site
SPTimeZone siteTimeZone = SPContext.Current.Web.RegionalSettings.TimeZone;

// currentTime will contain the current date and time according to the sites’ time zone settings
DateTime currentTime =  siteTimeZone.UTCToLocalTime(DateTime.Now.ToUniversalTime());

This will give you the current time in relation to the Site Regional Settings and will account for changes to the settings.

By |May 17th, 2014|Uncategorized|0 Comments|