1
0
-1

how can I make multiselect box readonly thru javascript and reader the same result as when you set multiselect as readonly in the form designer. I tried multiple scenarios and every option resulted in either the box disapearing or the box is empty. I want the box grayed out with select value grayed out too.


Thanks!

    CommentAdd your comment...

    6 answers

    1.  
      1
      0
      -1

      any update how to fix it

      1. Anders

        Hi, perhaps it could be due to the timing. An AJAX call takes a little while before it updates the element, so you could try adding a delay before using JavaScript to make it readonly, like https://www.w3schools.com/jsref/met_win_settimeout.asp

      CommentAdd your comment...
    2.  
      1
      0
      -1

      there must something to prevent AJAX from messing with the object.


        CommentAdd your comment...
      1.  
        1
        0
        -1

        any update how to fix it

          CommentAdd your comment...
        1.  
          1
          0
          -1

          any answers?

          1. Chris Angel

            Perhaps you can try out this code snippet below.

            FormUtil.getField('selectBoxFieldIdHere').attr('disabled',true)

            But do remember to set disable attribute back to false upon form submission, to allow the value to be stored successfully.

          2. Hamid Zahrir

            Thanks for the reply

            I did try this. like I said earlier I need to disable the option box but I need to see what was selected.

            this code will not show what was selected

          3. Hamid Zahrir

            I need it to show like this

          4. Hamid Zahrir

            I think II found the problem but I didn't find the solution

            when "Use AJAX for cascade options?" is checked I get an empty box when uncheked the code above works.  what's the solution to this?

          5. Hamid Zahrir

            definetly AJAX

            with AJAX enabled

            and when disabled 



            as you can see the AJAX override the chosen-single with chosen-default

            how can i disable ajax then the box is disabled



          CommentAdd your comment...
        2.  
          1
          0
          -1

          business rule requires it. when a grid contains rows the selection can't be changed until all rows from the grid are deleted then I will re_enable it. multiselect box is used for a single selection.

            CommentAdd your comment...
          1.  
            1
            0
            -1

            To clarify, what is the purpose of setting the multiselect box as readonly via JS? This can already be easily done via the multiselect box config in the Form Builder Multi Select Box#UI

              CommentAdd your comment...