Spice up Your Forms and Views Deep Dive into Client Side Rendering (CSR) Joe McShea Owner/Consultant IntelliPoint Solutions LLC.

Slides:



Advertisements
Similar presentations
SharePoint Forms All you ever wanted to know about forms but were afraid to ask.
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Customizing the SharePoint 2013 UI with JavaScript.
SPSVB 2015 Create Tailored Search Results w/ Display Templates SHAREPOINT SATURDAY VIRGINIA BEACH– JANUARY 10, 2015 MIKE ORYSZAK BLOG:
0 Leveraging External Data In SharePoint John Ramminger.
DEV392: Extending SharePoint Products And Technologies Through Web Parts And ASP.NET Clint Covington, Program Manager Data And Developer Services - Office.
Development models for on-premises Transformation approaches Farm solution considerations.
Becky Bertram SharePoint MVP
1 of 5 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2006 Microsoft Corporation.
1 Agenda Views Pages Web Parts Navigation Office Wrap-Up.
Branding SharePoint 2007 March 19, 2008 Lori Neff, SharePoint Designer.
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
A GUIDE TO SHAREPOINT 2007 CUSTOMIZATION OPTIONS Heather Solomon, WSS MVP.
JQuery CS 268. What is jQuery? From their web site:
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
JavaScript & jQuery the missing manual Chapter 11
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
EDUCATION YOU CAN TRUST ® Windows SharePoint Services Course Review Review provided by: DNS Computing Services, LLC
WorkPlace Pro Utilities.
5/5/2005Toni Räikkönen Internet based data collection from enterprises using XML questionnaires and XCola engine CoRD Meeting May 11th 2005.
09/28/ Cascade Server User's Conference1 Smart Cascade Server Implementations & Strategies 2009 Cascade Server User’s Conference Justin Klingman,
Developing Workflows with SharePoint Designer David Coe Application Development Consultant Microsoft Corporation.
SPSATL 2014 Create Tailored Search Results w/ Display Templates SHAREPOINT SATURDAY ATLANTA – JUNE 21, 2013 MIKE ORYSZAK BLOG: TWITTER:
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
SharePoint Branding with Design Manager. About James 7 years of SharePoint 2007, 2010, 2013 On-prem deployment planning, infrastructure setup, governance.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Deep Dive on SharePoint Ribbon Development and Extensibility Chris O’Brien SharePoint MVP Independent OSP433.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Sponsors Gold Silver Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
DHTML - Introduction Chapter Introduction to DHTML, the DOM, JS review.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Web User Controls This presentation will cover the basics of defining, creating and using a web user control. Presented to Twin Cities.NET user group By.
Selenium and Selenium on Rails. Agenda  Overview of Selenium Simple Selenium Tests Selenium IDE  Overview of Selenium on Rails  Problems with Selenium.
INTRODUCTION TO CSS. TOPICS TO BE DISCUSSED……….  Introduction Introduction  Features of CSS Features of CSS  Creating Style Sheet Creating Style Sheet.
Microsoft ® Official Course Developing a Publishing Site for Web Content Microsoft SharePoint 2013 SharePoint Practice.
Dawn Pedersen. What is JavaScript? JavaScript is the basis for both jQuery and Spry applications JavaScript is referred to as a client-side scripting.
The SharePoint Shepherd’s Course for End Users Based on the book by Robert L. Bogue Copyright 2011 AvailTek LLC All Rights Reserved.
Microsoft ® Official Course Designing and Managing Features and Solutions Microsoft SharePoint 2013 SharePoint Practice.
UNDERSTANDING YOUR OPTIONS FOR CLIENT-SIDE DEVELOPMENT IN OFFICE 365 Mark Rackley
Leveraging Web Content Management in SharePoint 2013 Christina Wheeler.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
Software services delivering SharePoint, Mobile, and Business Intelligence solutions Understanding and implementing the remote provision pattern in SharePoint.
Wes Preston DEV 202. Audience: Info Workers, Dev A deeper dive into use-cases where client-side rendering (CSR) and SharePoint’s JS Link property can.
Bob German Principal Architect Future-Proof your SharePoint Customizations: Build 2010 Solutions that become 2013 Apps.
DYNAMIC FAQ AND DOCUMENTATION PAGES IN SHAREPOINT A modern, reusable, and easy-to-use model.
DEV103 – Web Part Transformers – More than meets the eye By: D’arce Hess.
Best Web Technologies for
Basics Components of Web Design & Development Basics, Components, Design and Development.
SPEasyForms: The Free Forms Designer Solution for SharePoint Joe McShea Owner/Software Architect IntelliPoint Solutions LLC.
SPEasyForms: The Free Forms Designer Solution for SharePoint Joe McShea Owner/Software Architect IntelliPoint Solutions LLC.
Spice up Your Forms and Views with Client Side Rendering (CSR) Joe McShea Owner/Consultant IntelliPoint Solutions LLC 8/06/2016.
Testing and delivery Web design principles. Web development is software development.
Spice up Your Forms and Views
Joy Rathnayake Senior Architect – Virtusa Pvt. Ltd.
Spice up Your Forms and Views
Customizing SharePoint with TypeScript and Knockout
Developing GIS WebParts in SharePoint
Customizing SharePoint with Knockout and Typescript
Customizing SharePoint with TypeScript and Knockout
Microsoft Dynamics.
SharePoint Framework Extensions
SharePoint Online Development Best Practices
Customizing SharePoint with TypeScript and Knockout
Spice up Your Forms and Views
Customizing SharePoint with TypeScript and Knockout
SharePoint 2019 Overview and Use SPFx Extensions
Office 365 Development.
Bootstrap Direct quote from source: bootstrap/
Presentation transcript:

Spice up Your Forms and Views Deep Dive into Client Side Rendering (CSR) Joe McShea Owner/Consultant IntelliPoint Solutions LLC

Who Am I? Joe McShea IntelliPoint Solutions LLC Owner/Software Architect  Over 20 years as a software developer/architect  Focused on the Microsoft stack and SharePoint/Office 365 since 2007  Author of SPEasyForms, an open source forms solution for SharePoint 2010, 2013, and Online available for download on CodePlex  Contact  (twitter)  (blog) SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering 3/19/2016

Abstract I could have called this presentation ‘In Search of the Elusive Custom Field Type’, because they afford some functionality that is not easy to replicate with Client Side Rendering. This has more to do deployment issues, lack of documentation, and JSLink limitations than with the implementation of Client Side Rendering, so we’re going to be spending a bit of time talking about deployment. 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Target Audience & Objectives Who? Developers (including Citizen Developers) Show practical examples of CSR to customize forms (and possibly Views) Talk about gotchas MDS, deployment, JSLink limitations Demonstrate building components that can be easily reused by power users 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

What is Client Side Rendering In general, it just means pushing much of the presentation logic from the server (XSLT) to the client (JavaScript) In SharePoint, it is a framework for overriding the built-in presentation logic of new, edit, and display forms, views, and search results using HTML, CSS, and JavaScript - Depends on a mechanism for injecting JavaScript into one or more SharePoint pages 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Advantages of CSR 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering Performance Rendering logic is pushed from the server In SharePoint (XSLT) to the client (browser) Development Ease Few people like XSLT Many people are comfortable with HTML, CSS, and JavaScript Still need a fair amount of SharePoint domain knowledge Flexibility Only override parts of the view For instance, let SharePoint render most of the form, you just override methods for a single field

Disadvantages of CSR Performance…Um, Déjà vu The advantage should really have said Server Performance If the Browser sucks, or the client machine sucks, or the JavaScript code sucks, the performance is still going to suck from the user perspective Browser Compatibility If you’re in a closed environment where all users only have access to a single version of a single browser … Congratulations! Otherwise, there is a testing burden Third party libraries like jQuery can normalize this some, but go overboard and you can jump back to the second performance bullet 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

What is JSLink? A mechanism to inject JavaScript into various pages A property that can be set on various SharePoint objects - Form, Field, Content Type, View, List View Web Part (XLSTListViewWebPart) CSR depends on a mechanism to inject JavaScript - It does NOT depend on JSLink - There are other alternatives - In some cases, JSLink works quite well with CSR, in others it does not play well with CSR at all 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

What are we building? 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

And just as importantly 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Demo Star Rating CSR 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Deployment Options Set the JSLink property of a web part Deploy as a sandbox solution and declaratively set the JSLink on a Field or Content Type in the solution Set the JSLink property of a content type programmatically Set the JSLink property of a site column programmatically Add user custom actions to the web or site so the JavaScript is loaded on every page Place as stand-lone Display Templates in the Master Page Gallery 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Set the JSLink property of a web part Pros Very easy. Doesn’t require any additional code or packaging (i.e. it can be done OOB by a non-developer) Cons It’s really a one-off solution (i.e. not enterprise) Needs to be applied separately to the new, edit, and display forms Needs to be applied separately to each view in which your field is displayed (or might be displayed) If somebody adds a view later, or modifies a view later, it may need to be applied again If you want to use it in another list, start the whole process over again 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Deploy as a Sandbox Solution Pros Somewhat self documenting Can be deployed by an admin through the browser Cons It is a messy solution (i.e. does not uninstall cleanly) It leaves behind any instances like site columns Those columns still have their JSLink pointing the JavaScript Because it’s messy, it is almost impossible to upgrade Module files cannot be overwritten through upgrade Site Column instances need to be deleted before they can be upgraded, and therefore need to be deleted form any list using them (loss of data) 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Set Content Type JSLink Programmatically Pros It’s easier to manage than individually setting the JSLink on all columns Not exactly the same functionality as a custom field, but you do at least end up with a reusable component Cons JSLink on Content Types does not get called at all for Views; new, edit, and display forms only List Content Types do NOT get updated when you set the JSLink on site content types, even if you say push changes down Again it cannot be set on some content types…including Event (i.e. no calendars) and Survey The fact that JSLink is not supported doesn’t necessarily mean that CSR is not supported 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Set Site Column JSLink Programmatically Pros It seems like the right granularity, if you want to modify a field, modify it’s JSLink and you’ve modified it everywhere If you apply the same JS file as JSLink on two different fields, SharePoint is smart enough to only load it once Cons Some column types have a read-only JSLink property The fact that JSLink is not supported doesn’t necessarily mean that CSR is not supported It can be difficult to manage if you have a lot of columns with a lot of templates applies through JSLink, a well thought out utility page could help overcome this 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Add User Custom Actions Pros This is kind of the nuclear option, your code gets loaded everywhere (obviously, that can also be a con) Cons You need to make your code bullet-proof enough to run everywhere i.e. Site Settings -> Solutions -> Add Solution dialog loads your code; guess what…SPClientTemplates isn’t loaded It is pretty easy to do for CSR code, if SPClientTemplates is undefined, get out of Dodge; that’s probably all you need to do to make sure you don’t run on any non-form page, but you need to do it every time 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Display Templates in Master Page Gallery Pros Easy to deploy Even easier to reuse Cons I got nothin’, this is pure goodness 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Random Thoughts: What is the difference between JSLINK and Client Side Rendering? CSR is a framework for modifing SharePoint fields, views, forms, and search results in the browser. JSLink is nothing more than one of several mechanisms for injecting JavaScript into SharePoint pages. Using CSR depends on a method of getting JavaScript injected into the page, but not necessarily on JSLink. 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Random Thoughts: How can I run an external Script before CSR code is executed? If you're setting JSLink, the easiest way is that you can set it to multiple scripts separated by a pipe (|). Those scripts are executed synchronously in the order you specify them. CSR is smart enough to only load each script once, even if it is configured in the JSLink for multiple fields in the same form. If you're using a Display Template to customize a view for instance, you can load the external dependencies by setting ScriptLink user custom actions at the Web or Site level. ScriptLinks are always loaded before JSLink. 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Random Thoughts: Is CSR PostRender supposed to fire more than once? Yes. At least on forms, CSR PreRender fires once before each field override, then the override occurs, and the CSR Post Render fires. So it looks like: OnPreRender RenderTitle -> return HTML for the title field OnPostRender OnPreRender RenderBody -> return HTML for the body field OnPostRender Also, in your render callback you can call ctx.registerInitCallback passing in the field internal name and a callback function. These methods get called in the same order as the render methods, but none are called until ALL fields have been rendered. 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

Random Thoughts: Will I overwrite or append to existing validators with registerClientValidators? Once you call registerClientValidators, OOB validators will not fire automatically Required Field Validator You must add it to your validator set if you want it to fire Do not add it to the validator set if the current field is not required, check the field schema SharePoint forms will not let you save with an empty required field, but if you override validators and do not add the required field validator, no error message is displayed either 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering

References Martin Hatch, 7 part blog series on CSR Andrew Markeev, has several good CSR posts on Code Project Wictor Wilén, great write-up on CSR and MDS Office365 Developer Patterns and Practices github.com/OfficeDev/PnP Slides and Code from this presentation github.com/mcsheaj/CSRDemos 3/19/2016 SharePoint Saturday Chicago Suburbs - Spice up Your Forms and Views: Deep Dive into Client Side Rendering