jquery - Trying to call Javascript Function when SharePoint List View Web Part is filtered -


i have javascript colour row in sharepoint list view web part depending on values in column. part works fine , rows coloured correctly upon page load. issue have when list filtered (if click on of column headers , arrange ascending or descending order) formatting lost , colours disappear.

i'm looking way formatting stay or reapplied after filter action has completed. if page refreshed, filter selected remain in place , colours return.

i need way colours reapplied once filter has been applied instead of on page load.

thanks in advance.

here current js:

spclienttemplates.templatemanager.registertemplateoverrides({ onpostrender: function(ctx) {     var rows = ctx.listdata.row;     (var i=0;i<rows.length;i++)     {                     var trimmed = rows[i]["age"]         var final = trimmed.replace(",", "");         var oneweek = final < 7;         var onetotwo = final >= 7 && final <= 14;         var twoormore = final > 14;          if (oneweek)             {                 var rowelementid = generateiidforlistitem(ctx, rows[i]);                 var tr = document.getelementbyid(rowelementid);                 tr.style.backgroundcolor = "#ccffcc";              }          else if (onetotwo)             {                 var rowelementid = generateiidforlistitem(ctx, rows[i]);                 var tr = document.getelementbyid(rowelementid);                 tr.style.backgroundcolor = "#ffeecc";              }          else if (twoormore)             {                 var rowelementid = generateiidforlistitem(ctx, rows[i]);                 var tr = document.getelementbyid(rowelementid);                 tr.style.backgroundcolor = "#ffcccc";              }         }             } } 

);

so after ton of investigation, turns out formatting being overwritten @ last second after sort or filter had taken place.

the solution add end of code: ctx.skipnextanimation = true; skipped animation shows of rows falling place , allows formatting take effect should.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -