Changing SPFieldMultiChoice style on display form
- This topic has 5 replies, 2 voices, and was last updated 5 years, 7 months ago by .
Viewing 5 reply threads
Viewing 5 reply threads
- You must be logged in to reply to this topic.
Home › Forums › Classic DFFS › Changing SPFieldMultiChoice style on display form
Tagged: Multichoice display form
Multi choice fields (SPFieldMultiChoice) look terrible in display form (just a basic array separated by a semicolon ;)..
Choice 1;Choice 2;Choice 3
I know JSON can do it in a list view, is there a way to at least separate them into a new line in the Display form?
Choice 1
Choice 2
Choice 3
You can straighten it up by using this code:
function fixMultichoiceDisplay(fin){
var p = jQuery("#dffs_"+fin+" td.ms-formbody")
p.html(p.text().split("; ").join("<br>"));
}
// Use it like this
fixMultichoiceDisplay("Your_Field_Internal_Name");
Alexander
Awesome just what I wanted thanks
Hi Alexander,
This has been working great, but did cause an issues in another rule we did not immediately notice.
The rule checks the multi-choice field (same internal field name used in the code above)
IF XXX equals one of the values XXX, it hides/shows a tab.
When I add this JavaScript, the rules stops working.
If I remove it, the rule works again.
I guess once the choices have a <br> inserted instead of ; it breaks the rule somehow.
Any quick workarounds you could suggest?
Kind Regards,
Paul
Hi,
I think you can work around this by delaying the fixMultichoiceDisplay function until after the processing of the rules have finished.
Try it like this:
function dffs_ready(){
fixMultichoiceDisplay("Your_Field_Internal_Name");
}
Let me know how this works out.
Alexander
PS: Thanks for the donation!
Fantastic thank you worked like a charm