Thursday, May 23, 2013

Consuming SharePoint List (SPList) Data in Windows 8 HTML/JS app

Consuming SharePoint Data in Windows 8 HTML/JS app using SP Client Object Model
SharePoint offers different models for developing business solutions i.e.
  • Server Object Model
  • Client Object Model
    • .Net
    • JS
  • Asmx services
  • REST
SP Client Object Model enables to create SharePoint solutions that run remotely from the SharePoint server farm.
HTML/JS based Windows8 app can access data by consuming asmx or REST services directly but client object model offers more features as below Refer

But JS of Windows 8 app cannot consume SharePoint client object model directly so we have to develop the solution based on Windows Runtime Components, since Windows Store apps run on a new set of APIs called the Windows Runtime (WinRT). The Windows Runtime exposes components that are built as part of the Windows 8 OS along with third-party components you can develop yourself. Although some core Windows Runtime Components are accessible from desktop apps, third-party Windows Runtime Components are only available from within the Windows 8 environment.
Writing code in Runtime Component is as simple as writing code for other application in Visual Studio, however its execution in the environment is different. WinRT types are described using WinRT metadata files that have the .winmd extension. These files contain metadata definitions and semantics for classes and there is no code and component is part of the underlying OS.
WinRT project then consume the classes when you add the component as class library reference. Unlike regular C# class libraries, Windows Runtime Components can be called from any language that’s supported for creating Windows Store apps (core Windows Runtime Components that are part of the OS can be called from desktop apps as well). Consuming WinRT component in JS.

The Runtime component will query the SharePoint list (schema shown below) using client object model. Refer the attached code.

Rendering the data fetched from the SharePoint List in the Grid View the application will look like.


Post a Comment