Announcement

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

    Showing Default Filter Criteria in ListGrid FilterEditor

    When setting a default criteria for a ListGrid FilterEditor using filterData the criteria does not show up in the FilterEditor shown on the screen. Looking at the documentation for setShowFilterEditor I expected this to be displayed.

    This is something that is needed to show the user that a default criteria has been applied.

    Is there a way to make this appear?

    Here is some example code run in the ListGrid constructor:

    this.setShowFilterEditor(true);
    Criteria defaultCriteria = new Criterion("COLUMN1", Operator.Equals, 123);
    this.filterData(defaultCriteria);

    Here the filtering is applied, but I would expect 123 to appear in the filter for "COLUMN1" which it is not.

    Thank you in advance for any help on this.

    #2
    initialCriteria will only be shown in the FilterEditor if they are compatible with the operatorId configured for the field, otherwise, they are assuming to be additional criteria which should be applied but not shown to the user for editing.

    In this case, if you haven't customized things, the default operatorId is iContains (case-insensitive substring match).

    Comment


      #3
      Thank you for the quick response.

      I have this working for most of my fields now by creating Criteria that do not customize the OperatorId.

      The one case I cannot get working is to show that the a timedate field has an initial criteria of, for example, GREATER_OR_EQUAL to DateUtil.getAbsoluteDate(RelativeDate.YESTERDAY).

      Would you mind showing me a code block that makes this work if it is possible to do? This is important to show for this application.

      Thank you again.

      Comment


        #4
        Here's a simple snippet that shows a datetime field being populated with criteria, which are correctly shown in the filter-editor:

        Code:
               
                dateTestDS = new DataSource();
                dateTestDS.setClientOnly(true);
                
                DataSourceField datetimeField = new DataSourceField("datetimeField", FieldType.DATETIME);
                
                dateTestDS.setFields(datetimeField);
                
                ListGrid testGrid = new ListGrid();
                testGrid.setShowFilterEditor(true);
                
                testGrid.setDataSource(dateTestDS);
                
                Criteria testCrit = new AdvancedCriteria(OperatorId.AND, new Criterion[] {new Criterion("datetimeField", OperatorId.GREATER_OR_EQUAL, new Date())});
                
                testGrid.fetchData(testCrit);
                
                testGrid.draw();
        This is working for us. If it doesn't work for you, let us know exactly which SmartGWT version you're using and we'll take a look. Note - we're using 'fetchData(...)' here to apply the criteria to the grid, but using 'initialCriteria' if autoFetchData is true should work fine as well.

        Comment


          #5
          This is exactly what I needed. Thank you for your help!

          Comment


            #6
            I'm also trying to preset a filter value, in this case it's a combobox that represents a optiondatasource. So the real value to be set is an Integer.
            I use the following test code:
            Code:
            		Criteria criteria=new Criteria();
            		criteria.addCriteria("idtema", new Integer(2240));
            		boundList.setInitialCriteria(criteria);
            When I apply the initialCriteria, the comboBox is not set with the corresponding value; any suggestions how to achieve this?

            Comment

            Working...
            X