1 / 40

Customizing the SharePoint 2013 UI with JavaScript

Chris O’Brien - MVP. Customizing the SharePoint 2013 UI with JavaScript. About me. Independent Consultant Head of Development, Content and Code (UK) Blog: www.sharepointnutsandbolts.com Twitter: @ ChrisO_Brien LinkedIn: http://uk.linkedin.com/in/ chrisobrienmvp. Long Ago….

temima
Download Presentation

Customizing the SharePoint 2013 UI with JavaScript

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chris O’Brien - MVP Customizing the SharePoint 2013 UI with JavaScript

  2. About me • Independent Consultant • Head of Development, Content and Code (UK) • Blog: www.sharepointnutsandbolts.com • Twitter: @ChrisO_Brien • LinkedIn: http://uk.linkedin.com/in/chrisobrienmvp

  3. Long Ago… SharePoint 2007 CAML SharePoint 2010 XSL

  4. …Today SharePoint 2010 XSL SharePoint 2013 CSR

  5. Terminology • Lists • Fields • Web parts etc.. • Content Search web part • Search hover panel • List callouts

  6. JSLink • Used to transform: • Lists • Views • Fields • Web Parts • Content types

  7. CSR/JSLink – template scope • Use SPView.JSLink = ‘~site/foo/MyFile.js’, but also need to register templates • Register by: • BaseViewID (e.g. 1) • ListTemplateType (e.g. 10001) • ControlMode (e.g. ‘Display’)

  8. Registering templates/running code • The RenderContext JS object: • Templates collection • e.g. header, item, footer • Register with BaseViewID, ListTemplateType, ControlMode • OnPreRender • OnPostRender • ListData • ListSchema

  9. Using JSLink with SharePoint lists

  10. Advanced CSR possibilities • Modify list data/schema in OnPreRender • E.g. lookup something dynamically • Use SPClientRenderer.Render() to obtain HTML: • From arbitrary data • Outside of page context • In AJAX methods

  11. Customizing the Content Search web part

  12. Content Query vs. Content Search

  13. CSWP - 5 ‘easy’ requirements • “More like this” (Items matching a tag) • Recently changed items • Most popular items • “(Recent) items you may be interested in” (Matching current user’s profile) • “Items related to you” (Contributor to document)

  14. The role of Managed Properties • CSWP has mappings to Managed Props for data:

  15. CSWP and Display Templates These items are files in ~sitecollection/_catalogs/masterpage/Display Templates/ Content Web Parts

  16. Diagnostic item template • Diagnostic template gives raw (ish) output • Tip: configure many props temporarily

  17. Customizing the CSWP

  18. Dynamic values in query • Several tokens available:

  19. Search hover panel

  20. SP2013 search recap

  21. Hover Panel components

  22. Hover Panel components - Item_CommonHoverPanel_Body.js - Item_[FileType]_HoverPanel.js

  23. Hover Panel actions • Footer actions can also be • Common • Specific • Gotcha! Some item types do not use Common actions • E.g. Discussion - Item_CommonHoverPanel_Actions.js - Item_[FileType]_HoverPanel.js

  24. Customizing the search hover panel

  25. Hover panel – lessons learnt • Can’t use document.ready() – DOM is not populated • Specify function in ctx.OnPostRender instead • These functions are called ONCE (on first render [mouseover]) • N.B. Array of functions is accessible in all files e.g. header, body, actions etc. • DON’T delete _#= ctx.RenderBody(ctx) =#_ • This executes Item_CommonHoverPanel_Body.js (inheritance model)

  26. Summary • JavaScript is key to many SP2013 UI elements • Examples shown: • Customizing entire list UI • Conditional formatting of a field • Rendering of Content Search web part • Customizing search hover panel (inc. AJAX) • Lots of other possibilities too!

  27. CSWP/search Query Builder

  28. Script/CSS in display templates • Tools: • $includeScript • $includeLanguageScript • $includeCSS • But consider HTTP payload – may be better combining with other CSS/JS

  29. CSWP options

  30. Search display templates • Create the Display Template • Copy/rename then edit 2 files: • Item_Something.js [HTML] • Item_Something_HoverPanel.js [HTML] • Create any core search config • E.g. Managed Properties, Result Source • Create the Result Type Alternative - use search results WP properties to map to Display Template

More Related