Monday, 3 December 2012

Different Colors Using in Sharepoint 2010 Calendar Events



 I have created a team calendar mainly to share meetings, travels and vacations plans. Because I also wanted to manage differently those event types, I have created a Category for each of them.
·         Meeting
·         Holiday
·         Travel
·         Other
Here is my calendar with some information.

Click on the image to zoom

Because I think that color coding would help to easily identify event categories, I have created the following custom view (note that I have chosen not to display start and end time).


Here is the procedure to customize your calendar to be color coded.
Step 1: Create a new column [Color]. This will be used to define the color of the cell based on the category.
On the list settings page, click on Create Colum link. Name the new column “Color”, and set the type of information as Calculated (calculation based on other columns).
The formula is the following:
Finally, set The data type returned from this formula is: to Single line of text. 
=IF([Category]="","LightCyan",
IF([Category]="Meeting","DodgerBlue",
IF([Category]="Holiday","Tomato",
IF([Category]="Travel","LawnGreen",
IF([Category]="Other","DarkBlue","")))))
The result of this column will be a color name based on a category. Note that category should reflect ones you choose and color names can be changed.

Step 2: Create a new column [EventText]. This will contains the html code that will display the event text on the calendar view (including the color scheme).
As above, create a new calculated column with the following formula:

="<span style='position:relative;display:inline-block;width:100%;'>
<span style='width:100%;display:inline-block;text-align:center;border:1px solid "&[Color]&";position:absolute;color:"&[Color]&";'>"&[Title]&"</span>
<span style='display:inline-block;width: 100%;background-color:"&[Color]&";text-align:center;border:1px solid;z-index:-1;filter:alpha(opacity=20);opacity:0.2;'>"&[Title]&"</span></span>"
Note that we used the previously calculated column [Color] to define the cell color, and we also use column [Title] to display the event title inside the cell (you can also display Start Time and End Time if requested).
This is up to you to define your own style, this is simply html syntax.

Step 3: Define [EventText] column as the display on the calendar view.
You now need to create a new view for this calendar. This new view should be a Standard Calendar format view. Define properties as you wish. The important part is to display our newly created column [EventText] to replace the default Title.


Let’s now save the view and check the result.


Not so good isn’t itL. It displays the html code instead of interpreting it. To solve this, we need to insert JavaScript code into the page.
Here is the JavaScript code (such kind of code can be found in MSDN web site or in some blogs like techtrainingnotes.blogspot.com).


// Color coded calendars for SharePoint 2010
<script>

// TechTrainingNotes.blogspot.com
// load our function to the delayed load list
_spBodyOnLoadFunctionNames.push('colorCalendarEventLinkIntercept');
// hook into the existing SharePoint calendar load function
function colorCalendarEventLinkIntercept()
{
  if (SP.UI.ApplicationPages.CalendarNotify.$4a)
  {
    var OldCalendarNotify =
SP.UI.ApplicationPages.CalendarNotify.$4a;
    SP.UI.ApplicationPages.CalendarNotify.$4a = function ()
      {
        OldCalendarNotify();
        colorCalendarEventLinks();
      }
  }
  if (SP.UI.ApplicationPages.CalendarNotify.$4b)
  {
    var OldCalendarNotify =
SP.UI.ApplicationPages.CalendarNotify.$4b;
    SP.UI.ApplicationPages.CalendarNotify.$4b = function ()
      {
        OldCalendarNotify();
        colorCalendarEventLinks();
      }
  }
  // future service pack change may go here!
  // if (SP.UI.ApplicationPages.CalendarNotify.???)
}
// hide the hyperlinks
function colorCalendarEventLinks()
{
// find all DIVs
  var divs = document.getElementsByTagName("DIV");
  for (var i=0;i<divs.length;i++)
  {
    // find calendar item DIVs
    if (divs[i].className.toLowerCase()=="ms-acal-item")
    {
divs[i].innerHTML = divs[i].innerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>');
    }
    // find "x more items" links and re-remove links on Expand/Contract
    if (divs[i].className.toLowerCase()=="ms-acal-ctrlitem")
    {
      var links = divs[i].getElementsByTagName("A");
      if (links.length==1)
      {
       links[0].href="javascript:colorCalendarEventLinks();void(0);"
      }
    }
  }
}
</script>
To include the code into the page, there are 2 solutions:On SharePoint Designer, open your SharePoint site. On the left menu, select Lists and Libraries, then click on your Calendar name on the main screen. Right Click on the view you want to color code (or create a new one first) and select Edit File in Advanced Mode.
·         Using SharePoint Designer, the JavaScript code will be added to the page code directly
·         Using Content Editor Web Part, the JavaScript code is embed in a WebPart.

Using SharePoint Designer

Identify the section below to copy your JavaScript code inside

Save and check the result.

You can choose to leave items like this or modify CSS styles to remove the green box around your events.
Search the section <style type="text/css"> and replace with this: 
<style type="text/css">
.ms-acal-time {
  display:none;
}
.ms-acal-selected, .ms-acal-item {
  background:none;border:0px;
}
.ms-acal-sdiv span {
  margin-left:-47px;
}
.ms-acal-sdiv div.ms-acal-title span {
  margin-left:0px;
}
</style>
Save and check the result. Now we have the expected result J.
Using Content Editor Web Part
First of all, the script above should be saved into a txt document and uploaded in one of your site library.

On your custom Calendar View, select Edit page on the Site Actions menu.
Add a Content Editor Web part to Main section; this web part is located under Media and Content category. Edit the web part. Set ContentLink to your script document’s URL andChrome type to None (this will remove web part title and borders)


Save and check the result.
The drawback of this solution is that you will not be able to select other views for this calendar,
where with the SharePoint Designer method, all views are still accessible.

Because of this I prefer to use the using the Contant Editor webpart.
Result was like that.
if we have to remove the time in events mean
using this css
.ms-acal-time {
  display:none;
}
.ms-acal-selected, .ms-acal-item {
  background:none;border:0px;
}
.ms-acal-sdiv span {
  margin-left:-47px;
}
.ms-acal-sdiv div.ms-acal-title span {
  margin-left:0px;
}
After using css result is

Thats it.



Wednesday, 28 November 2012

Ajax Control Toolkit working with SharePoint 2010?

In this article,how we can use the Ajax Control Toolkit in Sharepoint 2010.using this sharepoint designer and Visuval studio.


1.Download the Ajax Control Toolkit from this url Click here.

2.Add Ajax Control Toolkit ScriptManager in your master page.Open the Master page in SharePoint Designer.

  •  First register the Ajax Control Toolkit namespace in the masterpage file by putting the following line at the top of the file     
                   <%@ Register Assembly="AjaxControlToolkit, Version=3.0.30930.28736,
                             Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"

                            Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %

  • Then remove the ScriptManager registration from the master page by removing the following line:


  <asp:ScriptManager id="ScriptManager" runat="server" EnablePageMethods="false"
 EnablePartialRendering="true" EnableScriptGlobalization="false" 
 EnableScriptLocalization="true"/>


  • Finally Add the following line in place of the above line to register Ajax Control Toolkit
      <ajaxToolkit:ToolkitScriptManager id="ScriptManager" runat="server" EnablePageMethods="false"
     EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true"/>




3.Register Ajax Control Toolkit namespaces in SharePoint package Designer

                    First open the Package designer in Visual Studio (Package usually exists under Package folder in    Visual Studio). And then click the “Advanced” button in package designer window as shown in the image below. In that advanced tab you can add/edit assemblies to be registered safe as part of the deployment of the solution package. Click Add ==> “Add Existing Assembly”. The following image shows wizard to follow.

image

Figure 1: Package Designer’s Advance tab
In the “Add existing Assembly” window, add the following namespaces for Ajax Control Toolkit.


The following image shows the “Add Existing Assembly” window for AjaxControlToolkit dll.

image


Figure 2: Add/Edit Existing Assembly window
Now you can build and deploy the package and as a result of deployment, Ajax Control Toolkit namespaces will be registered as safe controls in web.config.

Adding Items to the Welcome Menu in SharePoint 2010


Adding a new menu item to the SharePoint welcome/user menu is fairly straight forward.

Thanks to Sohels blog for pointing me in the right direction.

First create a new empty SharePoint project in Visual Studio 2010, call it "MenuItemProject".



2011-08-30-AddingItems-01.jpg


Deploy as a farm solution and click finish.


2011-08-30-AddingItems-02.jpg

Add a feature to the project. In the solutions explorer box, right click on the feature node and add feature.


2011-08-30-AddingItems-03.jpg

Also in the solution explorer, right click the top menuItemProject node and add > new item.


2011-08-30-AddingItems-04.jpg

Add an empty Element called "MenuAdditionElement".


2011-08-30-AddingItems-05.jpg

Once added, open the menuAdditionElement > Elements.xml file.


2011-08-30-AddingItems-06.jpg
Replace the Elements.xml code with the following:


<?xml version="1.0" encoding="utf-8"?>
 <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <CustomAction
   Id="myCustomAction"
   GroupId="PersonalActions"
   Location="Microsoft.SharePoint.StandardMenu"
   Sequence="1000"
   Title="Google"
   Description="Search away">
     <UrlAction Url="http://www.google.com"/>
   </CustomAction>
 </Elements>

Save the Elements.xml file and then in the solutions explorer double click on the feature1.feature node.


2011-08-30-AddingItems-07.jpg

Ensure the MenuAddition Element is included in the items in the feature.


2011-08-30-AddingItems-08.jpg


Deploy the solution to your SharePoint server.

Once deployed, refresh your site home page and the new menu item should be visible.






Wednesday, 7 November 2012

How to anonymous users access to comment on a SharePoint 2010 blog

First step from the site actions drop down choose view all site content on the blogsite

Click on the comments list 

 And choose list from the ribbon and goto the List permissions as shown below

 You will then need to stop inheriting permissions for this list,
 Once you have broken inheritance your view on the ribbon will change as illustrated below you will need to click on anonymous access
Once clicked you will be presented with the dialogue box below you will have to change the settings to allow Add Items – Add items to lists this will enable your readers to post comments on your new shiny SharePoint Blog.


Friday, 26 October 2012

Import CSV(excel) file to SharePoint list

Here the import the more than documents to add the lists using the Power Shell  Commands.

1.we have to add the title of the list  and body of contents and expire date.its like this

and save as .csv format.

2.After that using this code in Notepad



Add-PsSnapin Microsoft.SharePoint.Powershell –ErrorAction SilentlyContinue
$csv = Import-Csv 'csv file path'

$web = Get-SPWeb -identity "Domin Name"

$list = $web.Lists["ListName"]

foreach ($row in $csv) {
$item = $list.Items.Add();
$item["Title"] =$row.Title
$item["Body"] =$row.Body
$item["Expires"] =$row.Expires
$item.Update()
}
Write-Host "Finished! Press enter key to exit." -ForegroundColor Green
Read-Host


and save as filename.ps1 format.
3.finally exect that file

Automatically created the contents on the particular list.


Wednesday, 17 October 2012

Only JavaScript and html slide show in Share Point


You Have to add the scrip in your Master Page .
 <script type="text/javascript">

var slideimages=new Array()
var slidelinks=new Array()
function slideshowimages(){
for (i=0;i<slideshowimages.arguments.length;i++){
slideimages[i]=new Image()
slideimages[i].src=slideshowimages.arguments[i]
}
}

function slideshowlinks(){
for (i=0;i<slideshowlinks.arguments.length;i++)
slidelinks[i]=slideshowlinks.arguments[i]
}

function gotoshow(){
if (!window.winslide||winslide.closed)
winslide=window.open(slidelinks[whichlink])
else
winslide.location=slidelinks[whichlink]
winslide.focus()
}
    </script>

How to configure the target audience for a web part in SharePoint 2010 sites?


Microsoft Office SharePoint Server 2010 enables custom audience targeting for content and sites. The purpose is to define audiences and content that are relevant to a user or a group. As server or site administrator, you can define audiences and content for a specific set of users or group.
The following steps will teach you how to complete the configuration.
Step 1. Create two users in Active Directory which names are “test1″ and “test2″.







Step 2. Log in SharePoint site with the administrator.
Step3. Go to Site Settings>Site collection features, start the “SharePoint Server Publishing Infrastructure” feature, then go to “Site collection navigation” to check if “Enable audience targeting” is selected.




















Step 4. Go to Site Settings>Site Permission>Create Group, create a group named “testinggroup” whose permission level is Full control, then add “test1″ to this group.















Step 5. Go to Settings>Site Permission >Grant permissions, create a user named “test2″ whose permission level is Full control.








Step 6. Now let me take our product SharePointBoost Password Reset web part as an example. In the web part zone click Edit web part. In the Advanced section of the web part tool pane add the “testinggroup” into the Target Audiences box and click OK.















Step 7. Log in SharePoint with “test1″ and “test 2″ respectively. You will see the difference as below.










When you log in SharePoint with “test1″, you will see the Password Reset web part, and when you log inSharePoint with “test2″, you will not see the web part. This shows we have set the target audience successfully.

Thursday, 11 October 2012

Toggle in Picture Sliding Webpart and Video Webpart in Sharepoint 2010

In this toggle the Video webpart and Sliding webpart in sharepoint using the simple jquery.

1)First add the two webparts in sharepoint site and save it.
2)And than go to the SP designer.
3)Open the Particular Page and find the webpart(Video webpart and Sliding webpart) place.its like below


4)And arranged the with in the <td> tag.(img below)

5)After that create a hyper links on top of div tag.

6)Add the jquery coding on the bottom of the page and also refer the jquery-1.4.1.js.



 <script type="text/javascript">
        $(document).ready(function () {
            $('#slide_toggle').hide();
        });

        $(function () {
            $('#slide_toggle').click(function () {
                $('#slideWebpart').toggle();
                $('#videoWebpart').hide();

                $('#slide_toggle').hide();
                $('#video_toggle').show();
            });
        });

        $(function () {
            $('#video_toggle').click(function () {
                $('#videoWebpart').toggle();
                $('#slideWebpart').hide();

                $('#video_toggle').hide();
                $('#slide_toggle').show();
            });
        });
    </script>

6)finally save the page and see the output.



Tuesday, 9 October 2012

Expand and Collapse the SharePoint Web parts


1. Click on the Edit page Under "Site Actions".
2.Add Content Editor Web part any Zone.
3.Click on the Web part. "Click here to add content"
4.Click On "Edit Html Source" on the Ribbon.
5.Add following code.


<script type="text/javascript">
// Add the Web Part Titles here to have them opened by default
var wpsToSkip = ['Tasks','sandbox'];

function wpExpander() {
 var theTDs = document.getElementsByTagName("TD");
 for (var t=0;t<theTDs.length;t++) {
  var id = theTDs[t].id;
  if (id.match("WebPartTitleWPQ")) {
   id = id.substr(id.indexOf("WPQ"));
   var title = (theTDs[t].innerText || theTDs[t].textContent).replace(/[\n\r]/,'');
   var strImg = "<img style='margin:6px 5px 0px 2px;cursor:hand;float:left;' ";
   if (wpsToSkip.join().match(title)) {
    strImg += "onClick='showHide(\""+id+"\",this)' src='/_layouts/images/minus.gif'>";
   } else {
    strImg += "onClick='showHide(\""+id+"\",this)' src='/_layouts/images/plus.gif'>";
    document.getElementById("WebPart"+id).style.display = "none";
   }
   theTDs[t].innerHTML = strImg + theTDs[t].innerHTML;
  }
 }
}

function showHide(i,o) {
 var wp = document.getElementById("WebPart"+i);
 wp.style.display = (wp.style.display=="") ? "none" : "";
 o.src = (o.src.match(/plus.gif/)) ? "/_layouts/images/minus.gif" : "/_layouts/images/plus.gif";
}

_spBodyOnLoadFunctionNames.push("wpExpander()");
</script>



6.Make this Web part as Hidden.
7.Save and Close the web part.

or

As usual,  put this code into a Content Editor Web Part at the bottom of the page.

KendoUI Chart using in AngularJS with Dynamic data

Here i'm going to do the KendoUI Chart using AngularJS  and getting dynamic data from angular services. First need to down-lode the r...