cancel
Showing results for 
Search instead for 
Did you mean: 
thienphan
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

Hi Marian,

I downloaded the code from your link above. I placed it in Site Assets as your advice. However, I could not open it to review something as my specific case. Please show me how to do that?

0 Kudos
Reply
mlauer
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution
Reply
thienphan
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

Hi Manfred,

Thanks for your instruction. Unfortunately, my problem is how to create .js file.

0 Kudos
Reply
emha
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

it seems to me that you clicked on script and let it execute, so the script errored out since it was not started in proper context.

I'd suggest that you first customize it to your needs, upload it to sharepoint, and then try to run list view page

Reply
thienphan
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

Hi Marian,

My problem is that how to create .js file? I downloaded it from internet already, however, I could not open it to customize as my needs because that is that .js file.

0 Kudos
Reply
mlauer
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

You can edit js file with a text editor.

Reply
emha
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

if you have downloaded the script (.js file) you already have one created, haven't you?
then  you can edit/update it  in any plain text editor, like notepad.

if you haven't any yet, similarly open notepad, type in script code and save it with .js extension.

if your local system is configured to execute js file on doubleclick, do not doubleclick it but rather select by purpose Edit option from right click menu.
just once you have customized it, upload it to sharepoint. if you need to edit/change it once again, proceed just the same way - edit your local copy and then upload it to sharepoint.

0 Kudos
Reply
thienphan
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

Hi all,

I edited the code as my needs, and then uploaded to Site Assets. In the List View web-part properties, I inputted JS Link file (~sitecollection/Site Assets/FormatRowColor.js) to JS link property under the Miscellaneous Tab. However, it still don't work. I even tried to put the whole URL https://teamspace.healthcare.siemens.com/content/90002095/SiteAssets/Forms/AllItems.aspx/FormatRowCo.... The result is the same.

Could you show me what I did wrongly?

Thanks  

Reply
emha
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

what is that 'Javascript' at the very beginning? if it is really in your script, it will definitelly cause error.

are you aware that this recent version of script highlights just status field and not whole row as you requeted above?

~sitecollection/Site Assets/FormatRowColor.js

format of this path should be correct. question, however, is whether you really saved the script into sitecollection's SiteAssets library or site's one.

https://teamspace.healthcare.siemens.com/content/90002095/SiteAssets/Forms/AllItems.aspx/FormatRowCo...

this link is definitelly not correct, it refers to library page, not to file in library.

I believe it should be like

https://teamspace.healthcare.siemens.com/content/90002095/SiteAssets/FormatRowColor.js‍

I suggest to use first format of path.

to determine whether path is resolved correctly, once you are in list view open page source and search for your script name. check whether its path point to correct location.

btw, it's hard to follow any progress and provide sensefull hints if you switch to completely different script with different errors with every post....

Reply
thienphan
Nintex Newbie

Re: How to change row's color based on status field

Jump to solution

Hi Marian,

I did as your instruction at the beginning. However it didn't work. So I tried to use other code. I just come back to use your code as below:

<script type="text/javascript">
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {

   SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
     OnPostRender: function(ctx) {

       var statusColors =  {
          'Handover' : '#FF0000', 
          'Preparation' :  '#0000FF'

       };

       var rows = ctx.ListData.Row;
       for (var i=0;i<rows.length;i++)
       {
          var status = rows["Project Status"];
          var rowId = GenerateIIDForListItem(ctx, rows);
          var row = document.getElementById(rowId);
          row.style.backgroundColor = statusColors[status];
       }
     }
   });

});
</script>

And in the JS link, I entered the link

~sitecollection/Site Assets/FormatRowColor.js

So far, it didn't work. Could you help more

0 Kudos
Reply