Announcement

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

    Bug in setAlwaysShowOperatorIcon with fields disallowing filter operators

    Hi,

    SmartGWT 6.0p - SmartClient Version: v11.0p_2017-02-27/LGPL Development Only (built 2017-02-27)
    GWT 2.8.0

    With a ListGrid with filtering enabled, filter operators allowed and operator icon always shown, fields configured as "setAllowFilterOperators" break the draw of the grid with error

    com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot set property 'prompt' of undefined
    at Unknown.isc_ListGrid_updateOperatorIcon
    at Unknown.isc_ListGrid_setFieldSearchOperator
    at Unknown.isc_RecordEditor_draw
    at Unknown.isc_Layout_layoutChildren
    ...

    Reproducible with the following test case:

    Code:
        
         /*  
            com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot set property 'prompt' of undefined
            at Unknown.isc_ListGrid_updateOperatorIcon
            at Unknown.isc_ListGrid_setFieldSearchOperator
            at Unknown.isc_RecordEditor_draw
            at Unknown.isc_Layout_layoutChildren
            ...
         */
    
        public class OpGrid extends ListGrid {
            public OpGrid() {
                super();
    
                // setup filtering with operators
                setShowFilterEditor(true);
                setFilterOnKeypress(true);
                setAllowFilterOperators(true);
                setAllowFilterExpressions(true);
                // ... with operator icon always shown
                setAlwaysShowOperatorIcon(true);
    
                ListGridField gf1 = new ListGridField("f1");
    
                // this breaks things - comment this out and the grid works
                gf1.setAllowFilterOperators(false);
    
                ListGridField gf2 = new ListGridField("f2");
                setFields(gf1, gf2);
            }
        }
    
        public void doOnModuleLoad() {
            SC.showConsole();
    
            viewport = new VLayout();
            viewport.setWidth100();
            viewport.setHeight100();
            viewport.setOverflow(Overflow.HIDDEN);
    
            DataSource ds = new DataSource();
            ds.setID("myDS");
            DataSourceIntegerField f1 = new DataSourceIntegerField("f1");
            f1.setPrimaryKey(true);
            DataSourceTextField f2 = new DataSourceTextField("f2");
            ds.setFields(f1, f2);
    
            OpGrid g = new OpGrid();
            g.setDataSource(ds);
    
            viewport.addMember(g);
            viewport.draw();
        }

    #2
    Hi,

    this issue has been already fixed, you can check it out on next nightly build dated 2017-03-06.

    Thanks,
    Isomorphic

    Comment


      #3
      I have been testing this and encountered another problem. I've narrowed it down to the ListGrid.setFieldState method in grids.

      If the grid is configured as "setAlwaysShowOperatorIcon" and setFieldState is called on the grid, the filter editor loses all icons. I suspect this should not be the case: If the grid is configured to always show the icons, shouldn't they be shown regardless if the field state is set or not?

      Reproducible with the test case below: Click the button and observe that the icons get lost with a simple g.setFieldState(g.getFieldState()) call.

      Testing with NIGHTLY-2017-03-08 6.0p LGPL.

      Code:
        
          public class OpGrid extends ListGrid {  
              public OpGrid() {
                  super();
                  setShowFilterEditor(true);
                  setFilterOnKeypress(true);
                  setAllowFilterOperators(true);
                  setAllowFilterExpressions(true);
                  setAlwaysShowOperatorIcon(true);
                  ListGridField gf1 = new ListGridField("f1");
                  ListGridField gf2 = new ListGridField("f2");
                  setFields(gf1, gf2);
              }
          }
      
          public void doOnModuleLoad() {
              viewport = new VLayout();
              viewport.setWidth100();
              viewport.setHeight100();
              viewport.setOverflow(Overflow.HIDDEN);
      
              DataSource ds = new DataSource();
              ds.setID("myDS");
              DataSourceIntegerField f1 = new DataSourceIntegerField("f1");
              f1.setPrimaryKey(true);
              DataSourceTextField f2 = new DataSourceTextField("f2");
              ds.setFields(f1, f2);
      
              final OpGrid g = new OpGrid();
              g.setDataSource(ds);
      
              Button b = new Button();
              b.addClickHandler(new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent event) {
                      String state = g.getFieldState();
                      g.setFieldState(state);
                  }
              });
              viewport.addMember(b);
              viewport.addMember(g);
              viewport.draw();
          }
      Last edited by markok; 9 Mar 2017, 01:11. Reason: Added smartgwt version

      Comment


        #4
        This issue with setFieldState() (and refreshFields()) has been fixed for builds dated March 11 and later.

        Comment


          #5
          Excellent - We've tested this and everything now seems to work as expected.

          Comment

          Working...
          X