Announcement

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

    TextItem and others does not respect DataSourceField.setCanEdit(false) on DynamicForm

    Hi,
    There are two fields in DataSource, both with canEdit property set to false.
    The DynamicForm attached to this DataSource has corresponding items: one FormItem and one TextItem:
    Code:
        public void onModuleLoad() {
    
            DataSource ds = new DataSource();
            ds.setDataFormat(DSDataFormat.XML);
            ds.setDataURL("data.xml");
            ds.setRecordXPath("//country");
    
            DataSourceTextField pkField = new DataSourceTextField("countryCode");
            pkField.setPrimaryKey(true);
            pkField.setCanEdit(false);
    
            DataSourceTextField countryNameField = new DataSourceTextField("countryName");
            countryNameField.setCanEdit(false);
    
            ds.setFields(pkField, countryNameField);
    
            DynamicForm form = new DynamicForm();
            form.setDataSource(ds);
    
            FormItem pkItem = new FormItem("countryCode");
            TextItem countryNameItem = new TextItem("countryName");
            form.setFields(pkItem, countryNameItem);
    
            VLayout main = new VLayout();
            main.addMember(form);
            main.draw();
        }
    I would expect that both of DynamicForm items will observe and respect field's not editable attribute. Unfortunately the TextItem (and others like SelectItem) allows editing - the FormItem behaves the right way.
    Is it intentional ? Any suggestions ?
    MichalG

    #2
    I don't know if it's too late but the solution is :

    textItem.setAttribute("readOnly", true);

    Comment


      #3
      Thanks benmlahzied
      Definitely it should not be too late for SGWT library authors to consider this as their product improvement.
      MichalG

      Comment


        #4
        I've a similar isue but related with an editable grid.
        I've set de DataSoruce for the grid, then the fields with some setCanEdit set to true and other to false, and at the end grid.setCanEdit(true).
        But when a row is on edit mode all the fields become editable.
        If the setCanEdit is done at the data source definition it works ok.
        Any idea?

        Comment


          #5
          Originally posted by gmaurm
          But when a row is on edit mode all the fields become editable.
          Code:
          setEditByCell(true);

          Comment

          Working...
          X