Announcement

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

    How to display checkbox and not allow edit

    I have a database field which contains either a Y or N. I want it to display as a checkbox but I don't want it to be directly editable through the UI. The following definition does cause it to display as a checkbox, but it also allows it to be changed even with canEdit="false". Is there some other way to indicate that it cannot be changed, or should I use another method besides editorType="Checkbox"?
    Code:
    <field name="IREC" type="text" title="Reclassed?" detail="true"
      editorType="Checkbox" labelAsTitle="true" canEdit="false"> 
        <valueMap>
          <value ID="Y">true</value>
          <value ID="N">false</value>
        </valueMap>
    </field>

    #2
    That canEdit="false" setting should do it. Do you have a field definition in the ListGrid as well, or possible a ListGrid.canEditCell() override, that is reversing that setting?

    Comment


      #3
      It's actually in a DynamicForm where the editing remains enabled. Here's the code that sets up the form. Anything else I should try or any additional information I can supply to help find the problem.
      Code:
      itemForm.setDataSource(ipItemMasterDS);
      itemForm.setUseAllDataSourceFields(true);
      itemForm.setShowDetailFields(true);
      itemForm.setWidth("*");
      SubmitItem submit = new SubmitItem();
      submit.setTitle("Save Changes");
      itemForm.setFields(submit);
      itemForm.setSaveOnEnter(true);
      Last edited by jay.l.fisher; 23 Nov 2009, 18:53.

      Comment


        #4
        Normally the form implements a read-only field by switching to a StaticTextItem, but your explicit setting CheckboxItem prevents this. You can either:

        1) stick with the CheckboxItem but implement a change handler that always returns false to prevent editing

        2) use valueIcons to create the same appearance as a checkbox by pointing to the same image files used by the default checkbox

        Comment


          #5
          It seems like the valueIcons suggestion may be the easiest to implement, although it does seem like a workaround. canEdit="false" should be enough. Can I specify valueIcons in the data source xml? If so, can you point me to an example or tell me what the syntax should be?

          Comment


            #6
            You can specify valueIcons in the DataSource XML, it looks like:

            Code:
            <valueIcons storedValue="image/path" 
                             otherStoredValue="other/image/path"/>

            Comment

            Working...
            X