Item Template in JSLink With Group Rendering

Hi Friends.

I will explain a common problem and a solution for that while group rendering with JSLink.

Scenario

When rendering grouping in view with JSLink, we normally encounter an issue that an item rendering handler "overrideCtx.Templates.Item" is not being called. Group rendering was working fine in my case but not item-level rendering.

Solution

Initially I thought something was wrong with the JSLink file but after analyzing and debugging I found the problem is with the grouping configured in data view.

To fix this issue edit your data view and go to the grouping section of the view. Change the "By default, show groupings" setting to "Expanded" and save the view and bingo, it will start working.

The following image shows the setting in data view:



If you are provisioning data view declaratively then you need to add Collapse=”FALSE” to your <GroupBy> node.



The possible reason for this problem is, whereas the groups shown is in the collapsed state, the item in that group is not loaded initially and once you click to expand the group it will be loaded on demand hence the item template is not called initially as the items are not loaded.

I hope this will help some developers looking for the same kind of answer.

Happy coding!

Up Next
    Ebook Download
    View all
    Learn
    View all