Sharepoint 2013 JSLink (CSR) Not Working - sharepoint

I'm trying to make our list view as an accordion by following this tutorial:
https://code.msdn.microsoft.com/office/Client-side-rendering-code-ccdb2a0e
-
I followed the tutorial:
Create a Custom List, add a new column to the list:
Name: Description
Type: Multiple lines of text
Edit the Default New Form
Go to List view web-part properties and add the JSLink file (~sitecollection/Style Library/JSLink-Samples/Accordion.js) to JS link property under the Miscellaneous Tab. Click Apply.
-
Nothing changed, so I added a Script Editor in that page and pasted js code. Then it kind of works.
Is there anything I did wrong? Thanks!

Unfortunately the list view is rendered properly when Description field is type of Plain text from the specified example.
To render it properly when Description field is type of Rich text or Enhanced, replace the accordionTemplate function with this one:
function accordionTemplate(ctx) {
var title = ctx.CurrentItem["Title"];
var description = ctx.CurrentItem["Description"];
// construct List Item
return "<h2>" + title + "</h2><p>" + $(description).html() + "</p><br/>";
}
Result
I would recommend you to try another approach to render List View as accordion as demonstrated in Customize the rendering of a List View in Sharepoint 2013: Displaying List Items in Accordion article.
Key points:
jQuery IU Accordion is used for rendering List Items as collapsible
content panels
demonstrates how to load multiple JavaScript libraries (e.g. jQuery)
using JSLink property
Result

Related

Add list of item in editor view page of orchard cms driver class

I try to create custom content part with following specification.
I need to add list of items in database with same editor template view page of driver.
I want to include one form with required fields with an add button, by using this add button I want to add more number of rows with given field values in database.
I have checked Orchard documentation in this link, they provide sample with single item add in editor template page. In my case I need to add multiple items in editor page.
In display view page of driver, I want to retrieve collection of data from database and rendered in display view page.
Please share some details for this.
Thanks,

Orchard - show an Image from Media Library Picker Field

I created a new content definition, added a field "Media Library Picker Field" MYIMAGE.
There I can configure some things like "A content item is required" ... "Content Types and Parts" but I left them blank.
Then I can successfully select a image from my media library and see it from Admin/Contents/List.
Then I made a new query: I selected new layout, Html List, selected properties, add new property: "Title Part Title" with no configuration and MYIMAGE:Ids with no configuration.
Then I created a projection so I can see for every match of the query the titles BUT NO Ids.
I searched in shape tracing, i suppose I can find it in Zone[Content]->Content->List->PropertyWrapper (this is the first query result) and then under the Model Tab I suppose Model->Items->[0] should be the title so #Model.Items[1] should be the Ids.
How can I get the image's Id from #Model.Items[1]? And the URL?
This issue has been resolved. See https://orchard.codeplex.com/workitem/19956.
There is also a module called Vitus.Utils that adds some very useful tokens for Media Library items. See http://gallery.orchardproject.net/List/Modules/Orchard.Module.Vitus.Utils/1.0

Opening different xpages forms from a view panel

I have an Xpages application that pulls data from another .nsf file. I have a view panel linked to a view in that db. The view has documents with several different forms in it. I want to be able to open each document in it's own form(xpage).
How do I write a computed At Runtime, open selected document using: statement that will select the correct Xpage to present the document.
If you use the Data View component instead of a View Panel, you can compute the pageName attribute, referencing the var attribute to return a different value for each row based on the document that row represents. The flexibility of the Data View component also makes it easier to make your app look more like a modern web application and less like an Excel spreadsheet. As an additional bonus, the mobile theme invokes a renderer that makes each Data View instance look like a native mobile list, so using Data Views instead of View Panels simplifies mobile development.
You have 2 options:
use "use xpage associated with form" and edit the form's property
use a SSJS formula to compute the Form. You provide a variable name in the view control var to access a view row as XSPViewEntry. If the Form is in a view column even one you don't display you use .getColumnValue otherwise getDocument.getItemValueString
Does that work for you?
Maybe this mothed can help you: Unable to get document page name for
Hope this helps
Mark
I had a similar problem today. I use only one form but 3 different xpages for associated with this form. I have 3 different document types in the view. I used rowData the get the type of the document.
try{
var v=rowData.getColumnValue("form");
if(v.indexOf("x")> -1){var page ="x.xsp"}
else if(v.indexOf("y") > -1){var page = "y.xsp"}
else{var page = "z.xsp"}
}catch(e){
var page = "x.xsp"
}
So to your view you can create a column with the value of the form and you can use it.
I have used the extension library Dynamic View control which has an event you can code to get a handle to the NotesViewEntry which was selected. See the demo database page Domino_DynamicView.xsp and the Custom Event Handler tab for an example.
Note, in 8.5.3 (I have not upgraded yet) if you add or edit the eventHandler for onColumnClick it will be added to the XPages source as an xe:eventHandler. It needs to be an xp:eventHandler to work. The way to do it is to copy the code in the source from the exiting event and delete it. Recreate the event and update the code. Then go back into the source and change the tags within the eventHandler to xp:.

Find ID or Class of Sharepoint Document Library

I have a Mega Menu navigation that generates its content from custom lists. Each 'Tab' on the Mega Menu links to a different document library. I want to highlight the tab of the currently selected document library.
Each 'tab' already has a class attribute but I am having trouble giving the document library an ID or Class attribute, or finding one that is already there.
I have added a content editor web part in one of the document libraries, which is a blank html text file that has a body ID. When I reference it in the CSS I am able to achieve the highlighting of the tab when on that document library. However this only applies to the certain view that I am in. When changed to another view on the same document library (I have about 15-20 views) the highlighting disappears because there is no content editor web part in that view.
So to sum up - how can I use a universal ID or Class attribute that will not change each time a view is changed in a document library?
Thanks.
I ended up just using jQuery for this. Put it in my master page in a script tag.
if ( document.location.href.indexOf('<string in URL - I used the name of the document library') > -1 ) {
$('UL#topnav A.SecondTab').css('background-image', 'url(highlightedtab.jpg)');
}
Used several if statements because each tab has a different class name, e.g. FirstTab, SecondTab etc.

How can I present a library as a custom view?

I have a Sharepoint library that is currently rendering as the usual folder and document items table list view.
I would like to use present the same information as a grid of folder and document icons with some nice jQuery hover animations to show tooltips on the item the icon represents.
I suppose what I am really trying to find out is how to add a new library view that allows me to specify the markup rendered per item. I could write a new webpart to query the list and use an ASP:Repeater but I don't want to have to specify a webpart property each page to tell the webpart where it should open the list from.
You can use List View Web Part with custom XSLT.

Resources