Category Archives: SC Vinod

jQCalendarPart Mini SharePoint Calendar Web Part


You may also be interested in: fpweb.net


 

Editor’s note: Contributor SC Vinod is a SharePoint Developer at Hexaware Technologies. Follow him @scvinod

Introduction:

I always wanted everything to work on a full-fledged client side application in SharePoint. I’d like to thank the Client Object Model in SharePoint 2010, which inspired me a lot; though it was of no use in this application, unfortunately (but more on that later). Also, I wanted to use JavaScript/jQuery over Silverlight to get rid of that ugly “time out” message and the unnecessary task for the end users to download the Silverlight plugin.

This application is to integrate the jQuery Calendar control with the events added in a SharePoint Calendar list. This works in both SharePoint 2010 and SharePoint 2013.

Inspiration:

A similar application has already been developed and described here. It was developed by using SharePoint Server Object Model as a SharePoint web part by extending the ASP.NET calendar control but I wanted to make a completely client side application with slight functionality. I received help from this blog on how to query a SharePoint Calendar list using CAML query but it still really drove me crazy.

Description:

This is a JavaScript application developed using jQuery. The JS code, when added to a Content Editor Web Part in a SharePoint page, would display a jQuery calendar control synchronized with the SharePoint calendar list. Below, the list of features are explained:

  • The calendar control highlights the dates of all the upcoming events of the current month present in the Calendar list of the site.
  • The dates, when hovered over, would display a small pop-up showing the respective date’s events.
  • Below the calendar control would be the list of all the upcoming events of the current week.
  • The links, when clicked, would open the respective event’s page.

Look at the below image for a better understanding:

As you can see in the above image, cells 8, 9, 12, 13, and 14 are highlighted with a blue color border to show that these are the dates in the current month having events registered in the Calendar list. Below the calendar you can see the list of upcoming events of the current week. Also, when you hover over date “8” in the calendar you can see that a pop-up is being shown displaying the events of that particular date.

Hurdles:

Initially, I wanted to use SharePoint 2010 Client Object Model. Since it was not possible to retrieve recurring events using COM I had to use SharePoint list web services instead. This also had limitations, as I was able to retrieve only 30 events from the Calendar list in total which was not enough. So, I went ahead and used SPServices which resolved my problems to a great extent.

Limitations:

The web part will not work if you try to navigate to the next month or to the previous month. Please wait as I’m working on a fix to highlight all the dates which have events registered when a user is navigating to the next month.

Also, the name of the Calendar list should be “Calendar”. The code will not work if the list name is different since it has been hard coded.

Code:

I have used the jQuery DatePicker control and SPServices to get this application working. I have tested this on an Office 365 SharePoint 2013 preview site and it works fine too. But I wanted to develop it as an app and publish it in the app store for SharePoint 2013. So please wait until I get a SharePoint 2013 development environment.

Deployment Steps:

Since it is purely a client side application, we can simply deploy it by just moving the files. I assume that you have worked with CEWP before. I have explained the deployment process through the steps below:

  • Download the jQCalendarPart.zip file from here.
  • Unzip the jQCalendarPart.zip file.
  • Copy the unzipped jQCalendarPart folder into the layouts folder of SharePoint server.
  • Create a Content Editor Web Part in your SharePoint site where you want to display this web part.
  • Open the jQCalendarPart.min.js file from the jQCalendarpart folder and copy the content into the CEWP created above.
  • Save the page to see the web part showing a jQuery calendar control synchronized with the SharePoint calendar events from the Calendar list in your site.

SharePoint: Advantages and Disadvantages of the Client Object Model


You may also be interested in: SharePoint Hosting by Fpweb.net


 

Editor’s note: Contributor SC Vinod is a SharePoint Developer at Hexaware Technologies. Follow him @scvinod

I have implemented the Client Object Model (COM) extensively in Silverlight as well as in ECMAScript. I’ve failed many times in accomplishing certain tasks and succeeded many times too. You may love or hate COM but you cannot ignore it if you are a SharePoint 2010 developer.

So, I’m going to list the advantages and disadvantages of COM that I have faced while implementing it. Let’s look at the advantages first.

Advantages:

  1. As mentioned often, when using COM we can access SharePoint data from the client side browser itself with Silverlight and ECMAScript applications.
  2. Web parts with very rich user interface can be developed with the help of Silverlight and jQuery. For example, we can create web parts like video and image galleries with beautiful animations.
  3. COM along with JavaScript or jQuery can be implemented with just a Content Editor Web part within the browser or from SharePoint designer without opening Visual Studio. You can read about it here.
  4. When you save your site as a template. The application developed with an ECMAScript or Silverlight application implemented with Client Object Model would come along with the template which would be very helpful during migrations though we need to take care of any hard coded values.
  5. No IISREST is required while deploying a Silverlight or an ECMAScript application implemented with COM.
  6. We can have SharePoint accessed from the client desktop using Windows forms applications implemented with COM. We can develop desktop gadget kind of applications which would display the new announcements added to the “Announcements” list.
  7. No SharePoint installation is required in the development machine. Only the dll’s are required if you are going to develop Silverlight applications.

Disadvantages:

  1. We cannot elevate the privilege or Impersonate in COM as in the Server Object Model. That is, we cannot use the RunWithElevatedPrivilege kind of a delegate. Therefore, the result retrieved using COM will always be security trimmed by default.
  2. The range of classes available to access SharePoint data is very limited in COM. For example, we do not have Classes for accessing User Profiles. Though it can be accomplished by using SharePoint web services.
  3. We cannot access the objects of another site collection in COM while implementing in Silverlight or in an ECMAScript. We will get “The security validation for this page is invalid.” if we try to do so. So, we cannot develop applications to read the data from another site collection.
  4. Silverlight web parts fail to load by giving an error message saying Could not download the Silverlight application or the Silverlight Plugin did not load. To re-configure the Web Part or to provide a different Silverlight application (.xap), open the tool pane and then click Configure.if it takes more than 5 seconds to load. This means we have to finish loading the SharePoint data within 5 seconds.

Advantages and Disadvantages of LINQ to SharePoint over CAML Queries


You may also be interested in: SharePoint Hosting by Fpweb.net


 

Editor’s note: Contributor SC Vinod is a SharePoint Developer at Hexaware Technologies. Follow him @scvinod

2012-03-05-LINQtoSharePoint-01.pngThe LINQ to SharePoint functionality which was available as a third party tool for free in codeplex for MOSS 2007 is available as an inbuilt functionality in SharePoint Server 2010.

I’m not going define what LINQ to SharePoint is as it is out of the scope of this post. I’m going to list out the advantages and the disadvantages of LINQ to SharePoint over CAML queries that I have encountered (though there are lots of blogs covering this topic). Let us review the advantages first.

Advantages:

1. As is mentioned often, it provides strongly typed objects, which when using we get intellisense while coding. So, our code will be more bug free unlike the CAML Queries where the result will be known only in the run time.

2. One advantage not mentioned generally is that we can compare two columns (fields) of a SharePoint list in LINQ queries which is not possible in CAML queries.

3. We can also use LINQ to SharePoint to generate some complex CAML queries as shown in this blog

Disadvantages:

1. During the run time the LINQ query itself gets converted into a CAML query, which is an extra step ahead that takes more time . This can be avoided if we write a CAML query itself straight away.

2.  Also, we generate a DataContext class using the SPMetal.exe. This class is the one which we use in our project to generate LINQ queries. This class is not generated dynamically. So, if we do any changes in any of the lists or libraries in our site it is not reflected in the DataContext class. We have to generate a new class whenever we make any changes in the site.

3. Unlike CAML queries, LINQ to SharePoint has no use if we are going to access SharePoint data in Silverlight using Client Object Model.

4. Fields like Created, CreatedBy, Modified and ModifiedBy of a SharePoint list are not created by SPMetal to be used in the LINQ queries.

5. LINQ to SharePoint cannot be implemented for an External list.