I have created one page and added a list view web part on it.

I have added JSLink in Web part properties for client side rendering. All is working well but I want to get the currently selected View name to get specific view data.

How can this be done?

  • You are not getting list items, right ?.. is that mean there is something wrong with the rendering of your view? Can you please provide more information... Commented Jan 11, 2017 at 12:01
  • 1
    I presume you do work with Cisar, github.com/andrei-markeev/cisar Commented Jan 11, 2017 at 12:02
  • my view have enabled grouping so rendering data gives only gouping field details like Grouping field value, item count etc. i want all items of view. Commented Jan 11, 2017 at 12:28

2 Answers 2

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {  
    OnPostRender: function(ctx) {  
       var viewtitle = ctx.viewTitle;
        console.log("Your View Name" + viewtitle );     
  • it's working if i add JSLink on list's default page, but it's not working on other pages. Commented Jan 11, 2017 at 12:26
  • add this in to script file and add link to JS link in that webpart, write back to a global variable
    – Shiva
    Commented Jan 11, 2017 at 12:28
  • i have already tried it. Commented Jan 11, 2017 at 12:31
  • Please check the below answer
    – Shiva
    Commented Jan 11, 2017 at 12:45

It works.check below console. Added inthe script referred to JS link. Please find below image for the above answer

Add JS to App part in custom page

  • the view guid is current list view web part's current view's guid, there isn't available any view with this guid in list settings. just go to list setting and compare all view's guid with this one. Commented Jan 11, 2017 at 13:15
  • This view is dynamicaaly genearated and will not be avaible in the list settings. if you want list data it is accessible via ctx.ListData
    – Shiva
    Commented Jan 11, 2017 at 13:28
  • But when we use grouping in view the ctx.ListData return only grouping field details like group field value, item count etc. it's not returning all fields value. Commented Jan 12, 2017 at 4:28
  • State all your requirements so that some one can correcty address the question
    – Shiva
    Commented Jan 12, 2017 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.