Announcement

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

    Formula Field Builder Issue

    Hello Isomorphic,

    I've come across an issue with the SmartGWT Formula Field Builder when accessed from the Advanced Column Picker. I would appreciate your guidance on whether I might be overlooking something or if this is a potential bug. Thank you for your assistance.

    Environment:

    GWT version: 2.11.0
    SmartGWT version: 13.0
    Development Mode: Super Dev Mode
    Browser: Chrome Version 120.0.6099.225
    Operating System: Windows 11 Pro

    Issue Description:

    When using the Formula Column Builder from the Advanced Column Picker, there is an issue with the "Save/Add Another" button. The problem occurs when creating multiple Formula Fields, and only the first one is added to the Advanced Column Picker, while both are added to the List Grid.

    Steps to Reproduce:

    Open Advanced Column Picker.
    Select "Add formula column" from the "Add Custom Fields" dropdown.
    Create a new Formula Field.
    Press "Save/Add Another" button.
    Create another Formula Field.
    Press "Save."

    Actual Outcome:

    Both new Formula Fields are added to the List Grid.
    Only the first Formula Field is added to the Advanced Column Picker.

    Expected Outcome:

    All new Formula Fields should be added to the Advanced Column Picker.
    Fields should not be added to the List Grid until the "Apply" button is pressed on the Advanced Field Picker.


    Sample Test Case:

    Code:
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.types.Autofit;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    
    import com.google.gwt.core.client.EntryPoint;
    
    public class FieldPickerSample implements EntryPoint {
    
        private ListGridField[] createFields(int fieldCount) {
    
            ListGridField[] fields = new ListGridField[fieldCount];
    
            for (int i = 0; i < fields.length; i++) {
                fields[i]= new ListGridField("field" + (i+1), "Field " + (i+1));
            }
    
            return fields;
        }
    
        private ListGridRecord[] createRecords(int recordCount, ListGridField[] fields) {
            ListGridRecord[] records = new ListGridRecord[recordCount];
            for (int i =0; i < recordCount; i++) {
                ListGridRecord record = new ListGridRecord();
                for (int j = 0; j < fields.length; j++) {
                    record.setAttribute("field" + (j+1), "Row " + i + ", Value " + (j+1));
                }
                records[i] = record;
            }
            return records;
        }
    
        private ListGridField[] getOrderedFields(ListGridField[] fields) {
    
            ListGridField[] orderedFields = new ListGridField[fields.length];
    
            int initialFieldIndices[] = { 20, 5, 197, 59, 17, 120, 152, 91,
                                          37, 101, 40, 9, 174, 29, 163 };
            int oldIndex, newIndex;
    
            for (newIndex = 0; newIndex < initialFieldIndices.length; newIndex++) {
                int fieldIndex = initialFieldIndices[newIndex] - 1;
                orderedFields[newIndex] = fields[fieldIndex];
                fields[fieldIndex] = null;
            }
    
            for (oldIndex = 0; oldIndex < fields.length; oldIndex++) {
                ListGridField field = fields[oldIndex];
                if (field != null) {
                    orderedFields[newIndex++] = field;
                    field.setHidden(true);
                }
            }
    
            return orderedFields;
        }
    
        public class MyListGrid extends ListGrid {
    
            public MyListGrid() {
                super();
    
                setID("pickableFields");
                setCanEditTitles(true);
    
                setAutoFitData(Autofit.BOTH);
                setAutoFitMaxColumns(8);
                setAutoFitMaxRecords(20);
                setAutoFitFieldWidths(true);
    
                setCanAddFormulaFields(true);
    
                setUseAdvancedFieldPicker(true);
                setFieldPickerFieldProperties("frozen");
    
                ListGridField[] fields = createFields(200);
                setFields(getOrderedFields(fields));
                setData(createRecords(20, fields));
            }
        }
    
        public void onModuleLoad() {
    
            MyListGrid grid = new MyListGrid();
    
            Canvas canvas = new Canvas();
            canvas.addChild(grid);
            canvas.draw();
    
            grid.editFields();
    
            canvas.draw();
        }
    
    }

    #2
    We've applied a fix for this issue back to SC/SGWT 11.1 and it should be present in the nightly builds dated 2024-01-27 or later.

    Comment


      #3
      Originally posted by sdc2152 View Post
      Hello Isomorphic,

      I've come across an issue with the SmartGWT Formula Field Builder when accessed from the Advanced Column Picker. I would appreciate your guidance on whether I might be overlooking something or if this is a potential bug. Thank you for your assistance.

      Environment:

      GWT version: 2.11.0
      SmartGWT version: 13.0
      Development Mode: Super Dev Mode
      Browser: Chrome Version 120.0.6099.225
      Operating System: Windows 11 Pro

      Issue Description:

      When using the Formula Column Builder from the Advanced Column Picker, there is an issue with the "Save/Add Another" button. The problem occurs when creating multiple Formula Fields, and only the first one is added to the Advanced Column Picker, while both are added to the List Grid.

      Steps to Reproduce:

      Open Advanced Column Picker.
      Select "Add formula column" from the "Add Custom Fields" dropdown.
      Create a new Formula Field.
      Press "Save/Add Another" button.
      Create another Formula Field.
      Press "Save." little runmo

      Actual Outcome:

      Both new Formula Fields are added to the List Grid.
      Only the first Formula Field is added to the Advanced Column Picker.

      Expected Outcome:

      All new Formula Fields should be added to the Advanced Column Picker.
      Fields should not be added to the List Grid until the "Apply" button is pressed on the Advanced Field Picker.


      Sample Test Case:

      Code:
      import com.smartgwt.client.data.Record;
      import com.smartgwt.client.types.Autofit;
      import com.smartgwt.client.widgets.Canvas;
      import com.smartgwt.client.widgets.grid.ListGrid;
      import com.smartgwt.client.widgets.grid.ListGridField;
      import com.smartgwt.client.widgets.grid.ListGridRecord;
      
      import com.google.gwt.core.client.EntryPoint;
      
      public class FieldPickerSample implements EntryPoint {
      
      private ListGridField[] createFields(int fieldCount) {
      
      ListGridField[] fields = new ListGridField[fieldCount];
      
      for (int i = 0; i < fields.length; i++) {
      fields[i]= new ListGridField("field" + (i+1), "Field " + (i+1));
      }
      
      return fields;
      }
      
      private ListGridRecord[] createRecords(int recordCount, ListGridField[] fields) {
      ListGridRecord[] records = new ListGridRecord[recordCount];
      for (int i =0; i < recordCount; i++) { 
      ListGridRecord record = new ListGridRecord();
      for (int j = 0; j < fields.length; j++) {
      record.setAttribute("field" + (j+1), "Row " + i + ", Value " + (j+1));
      }
      records[i] = record;
      }
      return records;
      }
      
      private ListGridField[] getOrderedFields(ListGridField[] fields) {
      
      ListGridField[] orderedFields = new ListGridField[fields.length];
      
      int initialFieldIndices[] = { 20, 5, 197, 59, 17, 120, 152, 91,
      37, 101, 40, 9, 174, 29, 163 };
      int oldIndex, newIndex;
      
      for (newIndex = 0; newIndex < initialFieldIndices.length; newIndex++) {
      int fieldIndex = initialFieldIndices[newIndex] - 1;
      orderedFields[newIndex] = fields[fieldIndex];
      fields[fieldIndex] = null;
      }
      
      for (oldIndex = 0; oldIndex < fields.length; oldIndex++) {
      ListGridField field = fields[oldIndex];
      if (field != null) {
      orderedFields[newIndex++] = field;
      field.setHidden(true);
      }
      }
      
      return orderedFields;
      }
      
      public class MyListGrid extends ListGrid {
      
      public MyListGrid() {
      super();
      
      setID("pickableFields");
      setCanEditTitles(true);
      
      setAutoFitData(Autofit.BOTH);
      setAutoFitMaxColumns(8);
      setAutoFitMaxRecords(20);
      setAutoFitFieldWidths(true);
      
      setCanAddFormulaFields(true);
      
      setUseAdvancedFieldPicker(true);
      setFieldPickerFieldProperties("frozen");
      
      ListGridField[] fields = createFields(200);
      setFields(getOrderedFields(fields));
      setData(createRecords(20, fields));
      }
      }
      
      public void onModuleLoad() {
      
      MyListGrid grid = new MyListGrid();
      
      Canvas canvas = new Canvas();
      canvas.addChild(grid);
      canvas.draw();
      
      grid.editFields();
      
      canvas.draw();
      }
      
      }
      Long Text Area, Rich Text Area, Multi-Select Picklist and Encrypted type fields cannot be referenced in a formula field expression.

      Comment


        #4
        Sorry, what do you mean? Those are all text, not numeric types, so they don't belong in a math formula. Also, those are not field types, but editors, and the last one ("Encrypted type fields") is not a concept in the framework (perhaps it's in your application code?).

        Comment

        Working...
        X