Skip to main content
deleted 70 characters in body
Source Link
Akhoy
  • 2.9k
  • 2
  • 19
  • 28

You can use a calculated column to achieve this. Create a calculated column and set return type as number. Then, simply change the calculated column formula from C#.

Update
A similar way to do this would be using JSLink. You can include the below script in a JS file and place it in your VS solution (typically in your _layouts mapped folder). You wouldn't be able to dynamically change the HTML string though.

(function () { // Using the fields override leaves the rest of the rendering intact but allows control over one or more fields in the view var overrideCtx = {}; overrideCtx.Templates = {}; // Add OnPostRender event handler to hide the column if empty overrideCtx.Templates.Fields = { 'Body':{'View':EmbedHTML} }; //Register the template override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })(); function EmbedHTML(){ var retVal = ctx.CurrentItem.Body; //to retrieve the field var HTMLAppendedString; if(ctx.CurrentItem.ID == ID) //id of item to change { HTMLAppendedString = "<b>"+retVal+"</b>"; //Custom HTML goes here. } else { HTMLAppendedString = retVal; } return HTMLAppendedString; } 

You can call this using
spfield.JSLink="location_of_JS_file"
spfield.Update();

Hope this helps you.

You can use a calculated column to achieve this. Create a calculated column and set return type as number. Then, simply change the calculated column formula from C#.

Update
A similar way to do this would be using JSLink. You can include the below script in a JS file and place it in your VS solution (typically in your _layouts mapped folder). You wouldn't be able to dynamically change the HTML string though.

(function () { // Using the fields override leaves the rest of the rendering intact but allows control over one or more fields in the view var overrideCtx = {}; overrideCtx.Templates = {}; // Add OnPostRender event handler to hide the column if empty overrideCtx.Templates.Fields = { 'Body':{'View':EmbedHTML} }; //Register the template override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })(); function EmbedHTML(){ var retVal = ctx.CurrentItem.Body; //to retrieve the field var HTMLAppendedString; if(ctx.CurrentItem.ID == ID) //id of item to change { HTMLAppendedString = "<b>"+retVal+"</b>"; //Custom HTML goes here. } else { HTMLAppendedString = retVal; } return HTMLAppendedString; } 

You can call this using
spfield.JSLink="location_of_JS_file"
spfield.Update();

Hope this helps you.

You can use a calculated column to achieve this. Create a calculated column and set return type as number. Then, simply change the calculated column formula from C#.

Update
A similar way to do this would be using JSLink. You can include the below script in a JS file and place it in your VS solution (typically in your _layouts mapped folder). You wouldn't be able to dynamically change the HTML string though.

(function () { // Using the fields override leaves the rest of the rendering intact but allows control over one or more fields in the view var overrideCtx = {}; overrideCtx.Templates = {}; overrideCtx.Templates.Fields = { 'Body':{'View':EmbedHTML} }; //Register the template override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })(); function EmbedHTML(){ var retVal = ctx.CurrentItem.Body; //to retrieve the field var HTMLAppendedString; if(ctx.CurrentItem.ID == ID) //id of item to change { HTMLAppendedString = "<b>"+retVal+"</b>"; //Custom HTML goes here. } else { HTMLAppendedString = retVal; } return HTMLAppendedString; } 

You can call this using
spfield.JSLink="location_of_JS_file"
spfield.Update();

Hope this helps you.

added 122 characters in body
Source Link
Akhoy
  • 2.9k
  • 2
  • 19
  • 28

You can use a calculated column to achieve this. Create a calculated column and set return type as number. Then, simply change the calculated column formula from C#.

Update
A similar way to do this would be using JSLink. You can include the below script in a JS file and place it in your VS solution (typically in your _layouts mapped folder). You wouldn't be able to dynamically change the HTML string though.

(function () { // Using the fields override leaves the rest of the rendering intact but allows control over one or more fields in the view var overrideCtx = {}; overrideCtx.Templates = {}; // Add OnPostRender event handler to hide the column if empty overrideCtx.Templates.Fields = { 'Body':{'View':EmbedHTML} }; //Register the template override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })(); function EmbedHTML(){ var retVal = ctx.CurrentItem.Body; //to retrieve the field var HTMLAppendedString; if(ctx.CurrentItem.ID == ID) //id of item to change {  return "<b>"+ctx.CurrentItem.Body+"<HTMLAppendedString = "<b>"+retVal+"</b>"; //Custom HTML goes here. Way to retrieve } else {  field is toHTMLAppendedString use= ctx.CurrentItem.Body.retVal; } return HTMLAppendedString; } 

You can call this using
spfield.JSLink="location_of_JS_file"
spfield.Update();

Hope this helps you.

You can use a calculated column to achieve this. Create a calculated column and set return type as number. Then, simply change the calculated column formula from C#.

Update
A similar way to do this would be using JSLink. You can include the below script in a JS file and place it in your VS solution (typically in your _layouts mapped folder). You wouldn't be able to dynamically change the HTML string though.

(function () { // Using the fields override leaves the rest of the rendering intact but allows control over one or more fields in the view var overrideCtx = {}; overrideCtx.Templates = {}; // Add OnPostRender event handler to hide the column if empty overrideCtx.Templates.Fields = { 'Body':{'View':EmbedHTML} }; //Register the template override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })(); function EmbedHTML(){ if(ctx.CurrentItem.ID == ID) //id of item to change return "<b>"+ctx.CurrentItem.Body+"</b>"; //Custom HTML goes here. Way to retrieve field is to use ctx.CurrentItem.Body. } 

You can call this using
spfield.JSLink="location_of_JS_file"
spfield.Update();

Hope this helps you.

You can use a calculated column to achieve this. Create a calculated column and set return type as number. Then, simply change the calculated column formula from C#.

Update
A similar way to do this would be using JSLink. You can include the below script in a JS file and place it in your VS solution (typically in your _layouts mapped folder). You wouldn't be able to dynamically change the HTML string though.

(function () { // Using the fields override leaves the rest of the rendering intact but allows control over one or more fields in the view var overrideCtx = {}; overrideCtx.Templates = {}; // Add OnPostRender event handler to hide the column if empty overrideCtx.Templates.Fields = { 'Body':{'View':EmbedHTML} }; //Register the template override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })(); function EmbedHTML(){ var retVal = ctx.CurrentItem.Body; //to retrieve the field var HTMLAppendedString; if(ctx.CurrentItem.ID == ID) //id of item to change {  HTMLAppendedString = "<b>"+retVal+"</b>"; //Custom HTML goes here.  } else {  HTMLAppendedString = retVal; } return HTMLAppendedString; } 

You can call this using
spfield.JSLink="location_of_JS_file"
spfield.Update();

Hope this helps you.

Updated answer to more correctly answer the question
Source Link
Akhoy
  • 2.9k
  • 2
  • 19
  • 28

You can use a calculated column to achieve this. Create a calculated column and set return type as number. Then, simply change the calculated column formula from C#.

Update
A similar way to do this would be using JSLink. You can include the below script in a JS file and place it in your VS solution (typically in your _layouts mapped folder). You wouldn't be able to dynamically change the HTML string though.

(function () { // Using the fields override leaves the rest of the rendering intact but allows control over one or more fields in the view var overrideCtx = {}; overrideCtx.Templates = {}; // Add OnPostRender event handler to hide the column if empty overrideCtx.Templates.Fields = { 'url''Body':{'View':EmbedHTML} }; //Register the template override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })(); function EmbedHTML(){ if(ctx.CurrentItem.ID == ID) //id of item to change return "<b>"+ctx.CurrentItem.Body+"</b>"; //Custom HTML goes here. Way to retrieve field is to use ctx.CurrentItem.Body. This will make the change for every row in the list } 

You can call this using
spfield.JSLink="location_of_JS_file"
spfield.Update();

Hope this helps you.

You can use a calculated column to achieve this. Create a calculated column and set return type as number. Then, simply change the calculated column formula from C#.

Update
A similar way to do this would be using JSLink. You can include the below script in a JS file and place it in your VS solution (typically in your _layouts mapped folder). You wouldn't be able to dynamically change the HTML string though.

(function () { // Using the fields override leaves the rest of the rendering intact but allows control over one or more fields in the view var overrideCtx = {}; overrideCtx.Templates = {}; // Add OnPostRender event handler to hide the column if empty overrideCtx.Templates.Fields = { 'url':{'View':EmbedHTML} }; //Register the template override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })(); function EmbedHTML(){ return "<b>"+ctx.CurrentItem.Body+"</b>"; //Custom HTML goes here. Way to retrieve field is to use ctx.CurrentItem.Body. This will make the change for every row in the list 

You can call this using
spfield.JSLink="location_of_JS_file"
spfield.Update();

Hope this helps you.

You can use a calculated column to achieve this. Create a calculated column and set return type as number. Then, simply change the calculated column formula from C#.

Update
A similar way to do this would be using JSLink. You can include the below script in a JS file and place it in your VS solution (typically in your _layouts mapped folder). You wouldn't be able to dynamically change the HTML string though.

(function () { // Using the fields override leaves the rest of the rendering intact but allows control over one or more fields in the view var overrideCtx = {}; overrideCtx.Templates = {}; // Add OnPostRender event handler to hide the column if empty overrideCtx.Templates.Fields = { 'Body':{'View':EmbedHTML} }; //Register the template override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })(); function EmbedHTML(){ if(ctx.CurrentItem.ID == ID) //id of item to change return "<b>"+ctx.CurrentItem.Body+"</b>"; //Custom HTML goes here. Way to retrieve field is to use ctx.CurrentItem.Body.  } 

You can call this using
spfield.JSLink="location_of_JS_file"
spfield.Update();

Hope this helps you.

updated answer
Source Link
Akhoy
  • 2.9k
  • 2
  • 19
  • 28
Loading
Improved answer
Source Link
Akhoy
  • 2.9k
  • 2
  • 19
  • 28
Loading
Source Link
Akhoy
  • 2.9k
  • 2
  • 19
  • 28
Loading