1

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... – Rohit Waghela Jan 11 '17 at 12:01
  • 1
    I presume you do work with Cisar, github.com/andrei-markeev/cisar – Danny '365CSI' Engelman Jan 11 '17 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. – Trimantra Software Solution Jan 11 '17 at 12:28
1
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {  
  SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
    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. – Trimantra Software Solution Jan 11 '17 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 Jan 11 '17 at 12:28
  • i have already tried it. – Trimantra Software Solution Jan 11 '17 at 12:31
  • Please check the below answer – Shiva Jan 11 '17 at 12:45
0

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. – Trimantra Software Solution Jan 11 '17 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 Jan 11 '17 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. – Trimantra Software Solution Jan 12 '17 at 4:28
  • State all your requirements so that some one can correcty address the question – Shiva Jan 12 '17 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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