0

I am working on a rendering solution CSR (JS-Link) which uses the webpart ID list view to render.

Rendering a JS file is located in a library on the site.

The site is then registered model and automatically deployed.

The problem is that the ID of webpart view changes at each site deployment.

I must then copy the new ID to view pages and paste it into the JS file manually every new site. (see the illustration)

enter image description here enter image description here

So I'm looking for a solution that retrieves the new list webpart view ID on the page (based on the title or other), paste the ID in the JS file and saves.

Either each site deployment model (through PowerShell script for example) or with a JavaScript script located on the page but that is only executed one time (the first page opening).

1
  • updated my answer. Sep 17, 2015 at 19:19

1 Answer 1

2

You can get that GUID from WPQ4SchemaData.View Js Variable. But I'm not sure about the number here. It can be WPQ2/WPQ3/WPQ4. based on your webpart Order. Try it in your browser console and Get the correct number for your webpart. If you have a custom PageLayout with a fixed parent element id (Say #LVWPContainer). Then you can get the number by $('#LVWPContainer s4-wpcell-plain.ms-webpartzone-cell').attr('id'). It returns something like "MSOZoneCell_WebPartWPQ4" get the last number(4 into a variable say WID) and call window["WPQ"+WID+"SchemaData"].View .

You can also get the GUID by ctx.view. And ctx.wpq returns the string "WPQ2". if you dig more, you can see ctx is a container for WPQ2SchemaData i.e ctx.ListSchema is equal to WPQ2SchemaData and ctx.ListData is equals WPQ2ListData, etc. I believe ctx.view is the better variable to use in your case.

1
  • Thank you very much for your help sekhar I will explore this path to create a script, I hold you informed
    – ermo
    Sep 25, 2015 at 15:52

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.