2

Following the anwser from this post: JSLink: Is it possible keep the default list view header with column headers for filtering?

I managed to sucessfully register new template for rendering list items, retaining the default headers and such.

The problem is that the standard filter and sort functionality no longer work. Initially from what I can see is that, once a filter value is chosen, the list do not re-render/re-load contents of the list.

When an URL containing filter query is opened in new tab directly, list renders correctly. So when page initially opens and fetches all items, they all get rendered, and when filter is applied - all items are still rendered as if some event hasn't fired.

Am I missing some element, or a trigger, to tell sharepoint to re-render once a sort/filter is set?

(function () {
ExecuteOrDelayUntilScriptLoaded(_registerDemoViewTemplate, 'clienttemplates.js');

function _registerDemoViewTemplate() {
    // Initialize the variable that store the objects. 
    var overrideCtx = {};
    overrideCtx.Templates = {};
    overrideCtx.Templates.Header = RenderDemoViewHeader;
    overrideCtx.Templates.Item = ItemRenderCustom;
    overrideCtx.OnPostRender = OnDemoViewViewPostRender;
    // Register the template overrides. 
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
}

function OnDemoViewViewPostRender(ctx) {
}

function RenderDemoViewHeader(ctx) {
    return RenderHeaderTemplate(ctx);
}

function ItemRenderCustom(renderCtx) {

    var listItem = renderCtx.CurrentItem;
    var listSchema = renderCtx.ListSchema;
    var idx = renderCtx.CurrentItemIdx;

    var itemHTML = [];

    if (idx == 0) {
    }

    itemHTML.push(String.format('<Table class="RTEItem"><tbody><tr class="AddPadding"><td><strong>{0}</strong></td><td><strong>{1}</strong></td><td><strong>{2}</strong></td><td><strong>{3}</strong></td></tr><tr><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td></tr><tr><td>{8}</td><td>{9}</td><td>{10}</td><td></td></tr><tr class="AddSpace"><td>{11}</td><td>{12}</td><td>{13}</td><td></td></tr></tbody></table>',

        listItem.Name, listItem.Client,  listItem.Description, ParseDuration(listItem.Start), listItem.Title0, listItem.Project, listItem.Taxonomy, listItem.Start, listItem.Department, listItem.Task, listItem.Tags, listItem.Team, listItem.Workspace, listItem.Country));

    if (idx == renderCtx.ListData.Row.length - 1) {
    }

    return itemHTML.join('');



    };
})();

function ParseDuration(val) {
     DTFrom = new Date(val.substring(6,10), val.substring(3,5)-1, val.substring(0,2), val.substring(11,13),val.substring(14,16));
     DTTo = new Date();
     var dur = DTTo-DTFrom;
     var ms = Math.floor(dur/(1)) % 1000;
     var ss = Math.floor(dur/(1000)) % 60;
     var mm = Math.floor(dur/(1000*60)) % 60;
     var hh = Math.floor(dur/(1000*60*60));
     var dur2 = hh + "h " + mm + "m " + ss + "s";
     return dur2;
}

Thanks for help. Cheers,

Your Answer

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

Browse other questions tagged or ask your own question.