Hi there,
I want to format(change color) sharepoint form field labels using js link property of webpart
I am using the following code to achieve it
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: function(ctx) {
var rows = ctx.ListData.Row;
for (var i=0;i<rows.length;i++)
{
var isApproved = rows[i]["_ModerationStatus"] == "Approved";
if (isApproved)
{
var rowElementId = GenerateIIDForListItem(ctx, rows[i]);
var tr = document.getElementById(rowElementId);
tr.style.backgroundColor = "green";
}
}
}
});
Just got this piece of code from some site.The diifiulty is it is not working.
To render the js link I have saved the above script in ~sitecollection/_catalogs/masterpage/formatting.js
When I check using developer tool it gives me jquery is not defined error. Although I already have a jquery running on another list in the same site.
Can somebody please help me with this code or help with some code to achieve the task.
I know it can be easily done using infopath but I have a difficulty in using Infopath to achieve other requirements.
Many thanks in advance.
Any help will be highly appreciated.