Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ReadOnly fields vs. Disabled fields

    Hi,

    I have a need for something that's already been discussed long time ago on these forums,
    but for which I still haven't seen any implementation (Smartclient v8 GA).

    I need to have FormItem fields which support some read-only mode ...

    1) I need these fields to dynamically be able to change from read/write -> read/only state (and the other way around).

    2) I need users to be able to select/copy (clipboard) from read/only fields (disabled fields don't support this)

    Any idea if this feature is built-in but undocumented ? If not, how could I implement this elegantly ?

    Thanks,

    #2
    Hi,

    I just found that TextItem and TextAreaItem do support a readOnly property, although it isn't documented.

    Is it safe to use/rely on that property? It does seem to work ...

    Thanks,

    Comment


      #3
      Wouldn't rely on the internal readOnly property.

      You can implement this by adding a change() handler that rejects all changes, as well as changing textBoxStyle or other CSS styles to represent your own notion of a readOnly state.

      Comment


        #4
        The suggested approach worked like a charm. So I have my own internal _myReadOnly property
        which prevents change() events from going thru.

        For the record and for the others that might be looking for something similar, I also had to override
        the showPicker() method for some controls (DateItem, etc) and prevent it from going thru when my
        custom readOnly flag is set.

        Thanks,

        Comment


          #5
          Hi,

          IE has a feature where you enter <ESC><ESC> (press escape key twice) and it
          clears the underlying <FORM> content.

          This doesn't seem to trigger the Isomorphic change() event which I hooked up
          to prevent editing.

          Any suggestion on how I could handle this particular use case and prevent the
          form from clearing when my internal "read-only" flag is set?

          Thanks,

          Comment


            #6
            We have this calling resetValues(), since it's not really a per-field change.

            Comment


              #7
              Indeed, nuking the DynamicForm.resetValues() method resolves my problem.

              Thanks,

              Comment

              Working...
              X