0

I have been struggling with keeping the formatting on my list. When i filter, search, or sort, my formatting is removed from the affected rows. After some googling i found a solution; removing the animation from the list.

(function () {
    var overrideCurrentContext = {};
    overrideCurrentContext.OnPostRender = postRenderHandler;
    SPClientTemplates.TemplateManager.
                      RegisterTemplateOverrides(overrideCurrentContext);
})();

function postRenderHandler(ctx)
{
    var rows = ctx.ListData.Row;
    for (var i=0;i<rows.length;i++)
    {
        var row = document.getElementById(GenerateIIDForListItem(ctx, rows[i]));
        if(!(rows[i]["Column_x0020_1"] === ""))
            row.style.backgroundColor = '#3ea866';
    }
    ctx.skipNextAnimation = true;
}

Is there any way to keep the formatting and still keep the animation?

1

Learned something new today from your question..

OnPostRender is getting executed only on page load. From this link it seems we can hook the filter/sorting event via _spBodyOnHashChange

_spBodyOnHashChange = function({ 
    postRenderHandler(ctx);
    ajaxNavigate._raiseNavigate(ajaxNavigate);
}

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.