Changing SPFieldMultiChoice style on display form

Home Forums Classic DFFS Changing SPFieldMultiChoice style on display form

Viewing 5 reply threads
  • Author
    Posts
    • #32089
      Paul Lynch
      Participant

        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

      • #32091
        Alexander Bautz
        Keymaster

          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

        • #32093
          Paul Lynch
          Participant

            Awesome just what I wanted thanks

            • This reply was modified 4 years ago by Paul Lynch.
          • #33088
            Paul Lynch
            Participant

              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

            • #33090
              Alexander Bautz
              Keymaster

                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!

              • #33092
                Paul Lynch
                Participant

                  Fantastic thank you worked like a charm

              Viewing 5 reply threads
              • You must be logged in to reply to this topic.