Announcement

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

    Turn Off Display of List Grid Empty Cell Value in Filter Editor

    I have set an empty cell value for a field in a list grid. This works as expected and when the cells are empty, the empty cell text that I set is displayed within the list grid cells for that particular field. However, when I set can filter to false for this field with all other fields set to can filter of true, the empty cell value is displayed not only in the empty cells for this field, but also displayed within the filter editor cell as well.

    How can I prevent the filter editor, which is disabled, from displaying the empty cell text?

    Screen capture attached.

    -=> Gregg <=-
    Attached Files
    Last edited by gsl1; 17 Dec 2010, 13:52.

    #2
    Is this the expected behavior? If so is there any way to turn off the empty cell display in the disabled field filter but still have it display for the field cells?

    -=> Gregg <=-

    Comment


      #3
      Although it's possible to avoid this via setFieldEditotProperties and setting a default value, we'd recommend using a field of type "link" or a CellFormatter to get this behavior instead.

      Comment


        #4
        Thank you.

        That helps.

        Comment


          #5
          I finally had time to revisit this issue. Unfortunately, even if I use a cell formatter as suggested, if I set row 0 of the column to any value, the filter editor always gets set to this value as well, when the filter editor has "can filter" set to false. My code is as follows:

          Code:
          examDatesField.setCanFilter(false);
          // prompt user in each cell
          //        examDatesField.setEmptyCellValue("Click Here...");
          examDatesField.setCellFormatter(new CellFormatter() {
            @Override
            public String format(final Object value, final ListGridRecord record,
          					final int rowNum, final int colNum) {
              String output = (String) value;
              if ( (value == null || value.equals("")) && rowNum >= 0) {
                output = "Click Here...";
              }
              return output;
            }
          });
          This is the same behavior I see if I do not use the cell formatter and use the currently commented out code:

          Code:
          examDatesField.setEmptyCellValue("Click Here...");
          This column is currently set to use an option datasource and this works as expected---the dropdowns are displayed with list items when the user tries to edit the field.

          So again: is there a way that I can disable the filter editor for the column but set the data rows to display a value but NOT the filter editor, specifically set row 0 to have a value but not the filter editor?

          -=> Gregg <=-

          Comment


            #6
            Hi Gregg,
            This is more difficult than it should be. We'll look into making this more intuitive. However for now you can apply a CellFormatter to the ListGrid (not just to the field). This will be applied to the main ListGrid cells, but not to cells in the filter editor.
            Therefore if you do something like this:
            Code:
                    final ListGrid lg = new ListGrid();
                    ListGridField f1 = new ListGridField("f1");
                    f1.setCanFilter(false);
                            
                    lg.setCellFormatter(new CellFormatter () {
            
                        @Override
                        public String format(Object value, ListGridRecord record,
                                int rowNum, int colNum) {
                            if (lg.getFieldName(colNum).equals("f1") && value == null) {
                                return "ZZ";
                            }
                            return null;
                        }
                        
                    });
                    ListGridField f2 = new ListGridField("f2");
                    ListGridField f3 = new ListGridField("f3");
                    
                    lg.setFields(f1,f2,f3);
            You should see the "ZZ" showing up in the body of the listGrid but not of the filterEditor for the f1 field.
            Last edited by Isomorphic; 10 Dec 2015, 08:39.

            Comment


              #7
              Thank you for your reply and the example.

              This does indeed work; however, it suffers from a performance penalty, since the formatter must now check each field's type (e.g. date fields) and then format each cell into a string for output.

              It is not clear to me why the field formatter acts differently than the grid formatter. I would have expected the field formatter to act identically to the grid formatter but apply to just the specific field.

              Is there a good reason why they act differently in this use case?

              -=> Gregg <=-

              Comment


                #8
                We think that in the large majority of use cases, field-specific formatting rules should apply to values shown in the FilterEditor, but that this is far less likely to be appropriate for grid-wide rules (which are often things like data hilites or visual styling).

                Checking each field's type is not a significant overhead - realize there are a lot of rules being applied by the grid itself, regarding styling, hiliting, empty values, displayFields and all the other features the grid supports.

                Comment


                  #9
                  I have encountered this same issue while using both of these versions
                  v9.1p_2015-09-11/PowerEdition Deployment (built 2015-09-11)
                  v9.1p_2015-09-11/PowerEdition Deployment (built 2015-12-05)

                  Is there a better solution to this than setting a CellFormatter on the grid? I have a ListGrid with around 20 fields with varying formatting rules. I figured out a hack to work around this by checking the attributes in the ListGridRecord that is passed to format(). If the record has no attributes, then it is the record for the filter editor. I would rather not use my hack or the CellFormatter on the grid because I would need to rewrite a lot of code and re-order the grid's initialization. I set a CellFormatter on the grid to test it out, but it does not fire in my code.

                  Actually, the code below only works until a redraw occurs in the grid at which point the record is now populated with the attributes from each filter editor cell. I can still use logic to figure out if the record is the filter editor, but it isn't clean.

                  Code:
                              
                  @Override
                  public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                    if (record.getAttributes().length == 0) {
                      return null;
                    }
                    return  "formatted";
                  }
                  Last edited by brad_c; 9 Dec 2015, 23:41.

                  Comment


                    #10
                    As we noted above, most of the time, it makes sense to apply formatting rules in the FilterEditor row. For almost any example we can come up with - special date formatting, currency formatting, etc - the filterEditor would look broken if it skipped the formatter and displayed the raw value instead.

                    Is there something special about your formatting rules where they really don't make sense to apply to the FilterEditor row - for *all 20 fields*? This seems very strange.

                    Comment


                      #11
                      Just to add to this - rather than attempting to detect whether you're currently in the filterEditor from within the format method, it should be possible to use setFilterEditorProperties() on the listGrid to customize how the filterEditor recordEditor widget renders its cells. A custom cellFormtter applied to the filterEditor should override the cellFormatter applied to the main grid.

                      Comment

                      Working...
                      X