Archive | jQuery RSS for this section

jqGrid Implementation Using SpServices in SharePoint

Introduction

Today’s SPServices Story comes from Prateek Kulkarni in Bengaluru, India. Prateek posted this originally on the C# Corner site as jqGrid Implementation Using SpServices in SharePoint.

As with several of the earlier SPServices Stories posts, Marc found this one interesting because it shows how to use SPServices with another framework to render the results obtained from the Web Services calls.

Marc have had several people telling him that there isn’t enough “story” to these SPServices Stories. Have a better one? Let him know!

jqGrid with SPServices

This article is regarding implementation of jqGrid(demo) using SPService(CodePlex)

SPService is a jQuery library which abstracts SharePoint’s Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server installation.

Use of SPService and jQuery is best explained at Marc’s blog.

Following Js files are needed for JqGrid Implementation with SPService

  • jquery-1.8.2.js
  • grid.locale-en.js
  • jquery.jqGrid.min.js  // Structuring jqGrid
  • json2-min.js  // Parsing data to json format
  • jquery.SPServices-0.7.2.js  // For getting the list items

Css file required

  • ui.jqgrid.css  //Style sheet of Grid

HTML controls for jqGrid are as mentioned below.

1 <div id='tblMain' style="float:left">
2   <table  id="list" ></table>
3   <div id="pager" style="text-align:center;"></div>
4 </div>

Loading JqGrid on the page load:

1 jQuery("#list").jqGrid({
2   datatype: GetMyData,
3   colNames:["Project ID","Project Name","Delivery Manager","ApprovalStatus"],
4   colModel:[{name:'ProjectId',index:'ProjectId',align:'left',sortable: true},
5   {name:'ProjectName',index:'ProjectName',align:'left',sortable: true },
6   {name:'DeliveryManager',index:'DeliveryManager',align:'left',sortable:true},
7   {name:'ApprovalStatus',index:'ApprovalStatus',align: 'left',sortable: true }
8     ],
9   pager: true,
10   pager: '#pager',
11   pageinput: true,
12   rowNum: 5,
13   rowList: [5, 10, 20, 50, 100],
14   sortname: 'ApprovalStatus',
15   sortorder: "asc",
16   viewrecords: true,
17   autowidth: true,
18   emptyrecords: "No records to view",
19   loadtext: "Loading..."
20 });

In the above jqGrid load function Marc has mentioned the datatype for the grid as GetMyData() which is a function that gets triggerred first.

The GetMyData method has function GetDataOnLoad which uses the SpServices which has the basic operation of getting the list items i.e. GetListItems, which need optional CAML Query property which will fetch the data from list with some WHERE clause.

In the code Marc has a list called ProjectDetailsList which will contain details of some projects which are inserted by some Project Manager or delivery manager. So the requirement was when a user log in to the system one should get the current login user name and pass the same user name to the “where” clause of query so the grid will contain data of projects to which the current logged in user is assigned as PM or DM.

To get the current login user am using SpServices Operation SpGetCurrentUser.

The method GetTheOrderByType function will make the query part for SpServices.

The functions code is as follows:

1 function ForGettingUserName() {
2   var userName = $().SPServices.SPGetCurrentUser({
3       fieldName : "Title",
4       debug : false
5     });
6   return userName;
7 }
8
9 function GetMyData() {
10   sortIdexName = jQuery("#list").getGridParam("sortname"); //Maintaining Consitant SortName after the Sortcol event
11   sortOrderName = jQuery("#list").getGridParam("sortorder"); //Maintaining Consistant Sort Order
12   Query = GetTheOrderByType(sortIdexName, sortOrderName);
13   var CAMLViewFields = "<ViewFields>" +
14      "<FieldRef Name='projectName' /><FieldRef Name='projectID' />"
15      "<FieldRef Name='Title' /><FieldRef Name='deliveryManager' />"
16      "<FieldRef Name='projectSQA' /><FieldRef Name='approvalStatus' />"
17      "<FieldRef Name='projectStartDate' /><FieldRef Name='projectEndDate' />"
18      "<FieldRef Name='sqasiteurl' /><FieldRef Name='ID' />"
19      "</ViewFields>";
20   GetDataOnLoad(Query, CAMLViewFields);
21 }
22 Function for Getting the Query Type and the particular WHERE CLAUSE TO send the Query to GetListItem function
23 function GetTheOrderByType(index, sortOrder, userName) {
24   var OrderByType;
25   if (index == "ProjectName") {
26     if (sortOrder == "desc") {
27       OrderByType = "<Query>" +
28          "<Where><Or>" "<Eq>" "<FieldRef Name='deliveryManager'/><Value Type='Text'>"
29          + userName + "</Value>" "</Eq>"
30          "<Eq><FieldRef Name='projectManager'/><Value Type='Text'>"
31          + userName + "</Value></Eq>" "</Or></Where>" +
32          "<OrderBy><FieldRef  Name='projectName' Ascending='FALSE' /></OrderBy>" +
33          "</Query>";
34     else {
35       OrderByType = "<Query>" +
36          "<Where><Or>" "<Eq>" "<FieldRef Name='deliveryManager'/><Value Type='Text'>"
37          + userName + "</Value>" "</Eq>"
38          "<Eq><FieldRef Name='projectManager'/><Value Type='Text'>"
39          + userName + "</Value></Eq>" "</Or></Where>" +
40          "<OrderBy><FieldRef  Name='projectName' Ascending='FALSE' /></OrderBy>" +
41          "</Query>";
42     }
43   else if (index == "ApprovalStatus") {
44     if (sortOrder == "desc") {
45       OrderByType = "<Query>" +
46          "<Where><Or>" "<Eq>" "<FieldRef Name='deliveryManager'/><Value Type='Text'>"
47          + userName + "</Value>" "</Eq>"
48          "<Eq><FieldRef Name='projectManager'/><Value Type='Text'>"
49          + userName + "</Value></Eq>" "</Or></Where>" +
50          "<OrderBy><FieldRef  Name='approvalStatus' Ascending='FALSE' /></OrderBy>" +
51          "</Query>";
52     else {
53       OrderByType = "<Query>" +
54          "<Where><Or>" "<Eq>" "<FieldRef Name='deliveryManager'/><Value Type='Text'>"
55          + userName + "</Value>" "</Eq>"
56          "<Eq><FieldRef Name='projectManager'/><Value Type='Text'>"
57          + userName + "</Value></Eq>" "</Or></Where>" +
58          "<OrderBy><FieldRef  Name='approvalStatus' Ascending='FALSE' /></OrderBy>" +
59          "</Query>";
60     }
61     return OrderByType;
62   }
63
64   //This function gets the data from List using SpServices
65   Function GetDataOnLoad(Query, CAMLViewFields) {
66     $().SPServices({
67       operation : "GetListItems",
68       async : false,
69       listName : "ProjectDetailsList",
70       CAMLQuery : Query,
71       CAMLViewFields : CAMLViewFields,
72       completefunc : processResult
73     });
74   }

The processResult is the function which formats the data which can be converted to Json and adds to the JqGrid.
The reason of formatting of data in the following particular format is to make it readable by the Json parser which is json2.js file. Marc has implemented the same JqGrid in asp.net application with AJAX calls where it was returning the data in this format and some other bloggers also used the same data format in the MVC or asp.net application with the help for JsonHelper class which mainly formats the data returned from the DB

1 //Processing the XML result to formatted Json so that We can bind data to grid in Json format
2 function processResult(xData, status) {
3   var counter = 0; // Gets the total number of records retrieved from the list (We can also use xData.ItemCount method for counting the number of rows in the data )
4   var newJqData = "";
5
6   $(xData.responseXML).SPFilterNode("z:row").each(function () {
7
8     var JqData;
9     if (counter == 0) {
10       JqData = "{id:'" + $(this).attr("ows_projectID") + "',"
11          "cell:[" "'" + $(this).attr("ows_projectID") + "','" +
12         $(this).attr("ows_projectName") + "','" +
13         $(this).attr("ows_deliveryManager") + "','," +
14         "]}";
15       newJqData = newJqData + JqData;
16       counter = counter + 1;
17     else {
18       var JqData = "{id:'" + $(this).attr("ows_projectID") + "',"
19          "cell:[" "'" + $(this).attr("ows_projectID") + "','" +
20         $(this).attr("ows_projectName") + "','" +
21         $(this).attr("ows_deliveryManager") + "','," +
22         "]}";
23       newJqData = newJqData + JqData;
24       counter = counter + 1;
25     }
26
27   });
28   FinalDataForGrid(newJqData, counter);
29 }

That’s it. Add the data to the grid with the div control and the other page number calculation is for showing the pager.

1 function FinalDataForGrid(jqData, resultCount) {
2   dataFromList = jqData.substring(0, jqData.length - 1);
3   var currentValue = jQuery("#list").getGridParam('rowNum');
4   var totalPages = Math.ceil(resultCount / currentValue);
5   var PageNumber = jQuery("#list").getGridParam("page"); // Current page number selected in the selection box of the JqGrid
6   //formatting rows
7   newStr = "{total:" '"' + totalPages + '"' "," "page:" '"' + PageNumber + '"'","
8      "records:" '"'
9      + resultCount + '"' + ","
10      "rows:"
11      "[" + dataFromList + "]}";
12   var thegrid = jQuery("#list")[0];
13   thegrid.addJSONData(JSON.parse(newStr)); //Binding data to the grid which is of JSON Format
14 }

And the grid works fine and fast on paging, sorting and also even search, we can make the particular column as hyperlink which Marc will blog in the next part. Sample grid is as follows and this grid has some extra columns then the mentioned in above code.

This Post was originally posted at Marc D Anderson’s Blog

Advertisements

Pluralsight for MSDN Subscribers Worldwide

Back in June,  Pluralsight announced a special training benefit for MSDN designed to provide MSDN subscribers with access to 20 of their most popular courses.

Previously only available in the US, today they’re expanding this benefit to MSDN subscribers worldwide through December 11, 2012. Now you can access this benefit across the globe, regardless of location! See the notes below on who is eligible.

Based on our feedback, they’ve also worked with Microsoft to enhance this custom 12 month training subscription with several new Visual Studio 2012 courses.

The Pluralsight Starter Subscription for MSDN now contains 25 popular courses. The five new courses they added include:

  • Introduction to Visual Studio 2012 – Part 1
  • ALM with TFS 2012 Fundamentals
  • ALM for Developers with Visual Studio 2012
  • Microsoft Fakes Fundamentals
  • Intelllitrace

They’ve simply added these new titles to the original set of courses made available in June. If you’ve already taken advantage of this offer, you don’t have to do anything to get these – you’ll see the new courses show up in your account next time you login to Pluralsight.

 

 

 

To take advantage of this limited-time training benefit, redeem your Pluralsight Starter Subscription for MSDN by December 11, 2012:

Verify your MSDN subscription and register!

Feel free to download this PDF describing the benefit and email it to your friends and coworkers so they can take advantage of this offer too.

The Pluralsight Team hope we enjoy this MSDN training benefit!


Who is not eligible for this offer?

jQueryPad – Paul Stovell

jQueryPad

Download

jQueryPad screenshot

jQueryPad is xcopy deployable. It’s written in WPF and uses the Web Browser Control to embed Internet Explorer for testing the script. When you press F5, the HTML and JavaScript are combined into one file and rendered. The template also references jQuery, so the jQuery functions are available.

If you want to use a different version of jQuery or reference other files, just replace the files in the Templates directory.

Hope you find it useful – feature suggestions are welcome.

Source : http://www.paulstovell.com/jquerypad

 

SharePoint 2010 Learning Videos Links List!!

Here we go…..

Video: Ribbon highlights In SharePoint 2010

Video The ribbon is a new command interface that brings many SharePoint controls out from hiding and onto the page where they can do the most good. Similar to…

Video: Use breadcrumbs to find your way through a SharePoint site

Video When you’re lost on a SharePoint site, you can use breadcrumbs to see where you are in the site hierarchy or to go back up the tree to another level. SharePoint…

Video: Overview of PerformancePoint dashboard elements

Video Take a tour of a PerformancePoint dashboard and its various elements. Learn about Web Parts, filters, page navigation, and report types. See how you can…

Video: Explore data in PerformancePoint reports and scorecards

Video Learn how to investigate data in PerformancePoint reports and scorecards by using the various menu options, filters, and drilling techniques.

Video: Use the Quick Launch pane to find PerformancePoint dashboards and dashboard items

Video Learn how to use the Quick Launch pane on a SharePoint site to find PerformancePoint dashboards and dashboard items. The Quick Launch pane might contain…

Video: Open a PerformancePoint Web Part in a new window

Video Learn how to open a PerformancePoint Web Part in a new window, explore some of the things you can do in the new window, and how to close the window when…

Video: Applying filters to PerformancePoint reports or scorecards

Video Learn how to apply filters to PerformancePoint reports and scorecards. See how useful they can be when you explore and analyze data on a PerformancePoint dashboard.

Video: Export a PerformancePoint report or scorecard to PowerPoint

Video Learn how to export a report or scorecard from a PerformancePoint dashboard to Microsoft PowerPoint, and learn some tips and tricks for working with the…

Video: Export a PerformancePoint scorecard or report to Excel

Video Learn how to export a PerformancePoint scorecard or report to Excel and discover some tips for working with the exported data after it is in an Excel spreadsheet.

Video: Print a PerformancePoint dashboard or Web Part

Video Learn how to print a PerformancePoint dashboard or a Web Part, such as a scorecard, analytic grid, or pie chart. Find out how to make adjustments in Print…

Video: What’s New in PerformancePoint Dashboards

Video Watch this video to see some of the new features in PerformancePoint dashboards. You’ll learn about new report views, including analytic pie charts and…

Video: Enabling versioning in a SharePoint library

Video Learn how to enable and configure versioning in a SharePoint library. See how other settings, such as required check-out or required approval, affect the…

Video: View version history in a SharePoint library

Video Learn how to view version history in a SharePoint 2010 library, how to open a previous version, and how to compare that version with the current version

Video: Create a blog

Video See how you can quickly create a SharePoint 2010 blog site that you can use to share your knowledge with team members. This video shows you in less than…

Video: Link an Excel workbook to a SharePoint list

Video Learn how you can link an Excel 2010 workbook to a SharePoint 2010 list, and then configure Excel to refresh the data from the list, so you’re working with…

Video: Capture group knowledge in an enterprise wiki

Video This video provides an overview of the new enterprise wiki functionality in SharePoint Server 2010.

Video: Share knowledge in a blog

Video Learn how you can share your knowledge with team members in a SharePoint 2010 blog. This video gives an overview of the basic features and how you can use…

Video: Create personal views

Video This video explains how you can use views to organize and display the information in lists and libraries on SharePoint 2010 sites.

Video: Display a custom view on a page

Video This video shows you how to create a column, create a public view that’s based on the new column, and then display that view in a Web Part on a page on…

Video: SharePoint in Education – Lake Washington School District

Video In this video, several people from the Lake Washington School District (LWSD) talk about the implementation and use of a solution using SharePoint. The…

Video: SharePoint in Education – UW Foster School of Business

Video This video describes a SharePoint-based solution that enables people to browse through and view profiles of faculty members who teach at the Foster School…

Video: Custom social blog solution on SharePoint Server 2010

Video In this video, SharePoint MVP Yaroslav Pentsarskyy discusses a social blog solution he created for one of his clients. Inspired by other social websites…

Videos: SharePoint in Education

Article In the world of education, SharePoint is used internationally to create a platform where teachers, students, and parents can share information. Also, school…

Video: Use tags and notes to share information with colleagues

Video This video shows you how to use tags and notes to track or share information, or to receive updates when colleagues find or update information.

Video: Use Word 2010 to post to a SharePoint blog

Video When you use Microsoft Word to post to a S harePoint blog, you can create your blog post just as easily you would any other document. You can quickly check…

Video: Manage Digital Assets

Video This video provides an overview of the new features in SharePoint Server 2010 that enable you to work with rich media, such as image and video files.

Video: Navigate a team site

Video This video shows you how to navigate around a SharePoint 2010 team site to find content and resources.

Video: Navigate between SharePoint sites

Video This video explains how you can navigate between sites within a SharePoint 2010 site collection.

Video: Use Microsoft Word 2010 with SharePoint

Video This video demonstrates how you can create, update, and save documents to a SharePoint site from directly within Microsoft Word 2010. It shows how you can…

Download Office 2010 Help videos from Office.com

Article Download videos for Office 2010 from Office.com.

Source : http://office.microsoft.com/en-us/sharepoint-server-help/CL100315293.aspx?tl=3

Thanks and Have fun!!!!!

Exam 70-515 TS: Web Applications Development with Microsoft .NET Framework 4

Hi Guys,

I’m preparing for Exam 70-515 TS: Web Applications Development with Microsoft .NET Framework 4.

In this post, I’ll keep updating the materials, links, blogs, articles, etc which will help me as well as you guys to pass this exam.

1.

I read through Niall Merrigan’s summary posts of MSDN and various articles pertaining to the exam:

Post 1 of 6: http://www.certsandprogs.com/2010/03/mcts-web-applications-net-4-70-515.html#axzz1TJvkBAhk

Post 2 of 6: http://www.certsandprogs.com/2010/03/mcts-web-applications-net-4-70-515_22.html#axzz1TJvkBAhk

Post 3 of 6: http://www.certsandprogs.com/2010/03/mcts-web-applications-net-4-70-515_5119.html#axzz1TJvkBAhk

Post 4 of 6: http://www.certsandprogs.com/2010/03/mcts-web-applications-net-4-70-515_7210.html#axzz1TJvkBAhk

Post 5 of 6: http://www.certsandprogs.com/2010/03/mcts-web-applications-net-4-70-515_23.html#axzz1TJvkBAhk

Post 6 of 6: http://www.certsandprogs.com/2010/03/mcts-web-applications-net-4-70-515_1117.html#axzz0oCblHj8M

Best of luck!

Introducing Debugger Canvas : Released Now!!

About Debugger Canvas

Debugger Canvas is a new user experience for the debugger in Visual Studio Ultimate. It pulls together the code you’re exploring onto a single pan-and-zoom display. As you hit breakpoints or step into code, Debugger Canvas shows just the methods that you’re debugging, with call lines and local variables, to help you see the bigger picture.

Get Debugger Canvas

Try out Debugger Canvas, a new user experience for the debugger in Visual Studio Ultimate.

Install Debugger Canvas

Get Started

Download and Install Debugger Canvas.
Read the Guide to get started with Debugger Canvas.

Requirements

  • Visual Studio 2010 Ultimate SP1 (works with C# and Visual Basic)

Source : http://research.microsoft.com/en-us/projects/debuggercanvas/

%d bloggers like this: