0

I completely re-render my listviews via JSLink. To keep the original filter popup layout (and solve this problem) I use the onPostRender handler to move the table headers around a little bit. This is working very well.

The problem is: If I actually use the filter, SharePoint re-renders the List view without calling my PostRender function.

Can I trigger that elsewhere? Or is there a different event handler that I can use?

2
  • Is MDS enabled on that site? Commented Dec 11, 2015 at 14:38
  • Yes, I think so....
    – Dave
    Commented Dec 14, 2015 at 7:39

2 Answers 2

1

If MDS is enabled on that site you will need to use RegisterModuleInit() to register your rendering script with the MDS engine so that it is consistently run.

To do that you will need to give a named entry point to your rendering script that you can use in RegisterModuleInit(). So, your rendering script would have to change from:

(function() {
    var overrideCtx = {};
    // etc
    // etc
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();

to

function myCustomRendering() {
    var overrideCtx = {};
    // etc
    // etc
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
}

// register with MDS engine
// parameters are the URL/path of the script file, and the name of the function
RegisterModuleInit("/path/to/your/renderingScript.js", myCustomRendering);

// fallback for non-MDS sites, just call the function
myCustomRendering();

Here is a link to a blog post that explains it further.

1
  • I was wrong. A collegue of mine switched of MDS a couple of weeks ago. I haven't noticed. Sorry for that misleading information.
    – Dave
    Commented Dec 15, 2015 at 10:46
0

Found a (quick 'n dirty) workaround:

Added the function by hand to my Templates.Body override:

window.setTimeout(function() {csListView.postRender();}, 50);

But I still hope that there's a better solution!

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.