Customize SharePoint Calendar View Using JQuery

Standard

Note: This is working only with SharePoint 2010 as the notification changed

Calendar view in SharePoint is not a XSL view so when you come to customize it is not easy steps to change  it. To produce that you think like that:

1 – SharePoint calendar view bind its data from one field in your list which you can change it by modify the view. Great so you can add a calculated field that carry an HTML code and data from other fields to be displayed in the calendar cells and this will solve the problem……try that gonna work but the html code is rendered as a plain text in the calendar view. check the following figure:

Continue reading

Remove HTML Tags in SharePoint 2010

Standard

Always I’ve  faced the same problem and solved it in the same why when I deal with text fields in SharePoint which is remove the Html tags for the returned text to display it as a plain text. Each time my best solution is googling for the regular expression to replace Html tags with empty string 😦

Unfortunately  I find a method in Microsoft.SharePoint namespace to do this and offer also sub string for the returned text which is:

SPHttpUtility.ConvertSimpleHtmlToText(HTMLText , maxLength);

To remove tags and sub string it to max length

or

SPHttpUtility.ConvertSimpleHtmlToText(HTMLText , -1);

To remove tags only

Check If a List Contains a Certain Field

Standard

In a case I have to check if the current list contains a certain field or not I supposed that I have to do the following:

if(null == SPList.Fields[“CertainField”]){//do something}

but unfortunately this is not gonna work

after search I get the solution which is like the following:

if(SPList.Fields.ContainField(“CertainField”)){//do something}

Best regards 🙂

CAML Query for calender list

Standard

To get all events in current month:

<Where>
    <DateRangesOverlap>
        <FieldRef Name="EventDate" />
        <FieldRef Name="EndDate" />
        <FieldRef Name="RecurrenceID" />
        <Value Type="DateTime"><Month /></Value>
    </DateRangesOverlap>
</Where>

To get all todays events:

string PreviousDay = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd") ;
string NextDay = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd");
string query =
@"<Where>
    <And>
      <Gt>
        <FieldRef Name='EventDate' />
        <Value IncludeTimeValue='FALSE' Type='DateTime'>" + PreviousDay  + "</Value>
      </Gt>
      <Lt>
         <FieldRef Name='EventDate' />
         <Value IncludeTimeValue='FALSE' Type='DateTime'>" + NextDay  + "</Value>
       </Lt>
     </And>
</Where>";