Announcement

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

    FilterEditor in combination with ListGrid.setCriteria()

    When using the filtereditor, the listgrid looses its criteria set with setCriteria().

    (I heard that since 2.3, the programmatically set criteria were always applied and sticky, independently from the filtereditor criteria)

    This is my datasource definition:
    Code:
    <DataSource 
    	serverType="sql"
    	dbName="Mysql"
    	tableName="Customer"
    	ID="Customer"
    >
    	<fields>
    		<field primaryKey="true" type="sequence" name="cstm_pk" hidden="true"></field>
    		<field type="integer" length="10" name="cstm_number" title="" required="true" export="true"></field>
    		<field type="text" length="45" name="cstm_name" title="" required="true" export="true"></field>
    		<field type="text" length="4000" name="cstm_description" title="" export="true"></field>
    	</fields>
    </DataSource>
    This is my testcase:

    Code:
    public class CustomerGridTest implements EntryPoint {
    	public void onModuleLoad() {
    		VLayout layout = new VLayout();
    		layout.setHeight100();
    		layout.setWidth100();
    		
    		ListGrid grid = new ListGrid();
    		grid.setDataSource(DataSource.get("Customer"));
    		grid.setShowFilterEditor(true);
    		grid.setFilterOnKeypress(true);
    		layout.addMember(grid);
    		
    		Criteria crit = new Criteria();
    		crit.addCriteria("cstm_pk", 1);
    		grid.setCriteria(crit);
    		grid.fetchData(crit);
    				
    		layout.draw();
    		
    	}
    }
    This will result in the following request upon startup:

    Code:
     criteria:{
            cstm_pk:1
        },
        operationConfig:{
            dataSource:"Customer",
            operationType:"fetch",
            textMatchStyle:"exact"
        },
        startRow:0,
        endRow:75,
        componentId:"isc_ListGrid_0",
        appID:"builtinApplication",
        operation:"Customer_fetch",
        oldValues:{
            cstm_pk:1
        }
    When I fill in something in the filtereditor, it results in the following request (original criteria have disappeared)

    Code:
    criteria:{
            _constructor:"AdvancedCriteria",
            operator:"and",
            criteria:[
                {
                    fieldName:"cstm_description",
                    operator:"iContains",
                    value:"n"
                }
            ]
        },
        operationConfig:{
            dataSource:"Customer",
            operationType:"fetch",
            textMatchStyle:"substring"
        },
        startRow:0,
        endRow:75,
        componentId:"isc_ListGrid_0",
        appID:"builtinApplication",
        operation:"Customer_fetch",
        oldValues:{
            _constructor:"AdvancedCriteria",
            operator:"and",
            criteria:[
                {
                    fieldName:"cstm_description",
                    operator:"iContains",
                    value:"n"
                }
            ]
        }
    }
    Am I doing something wrong?
    (I was expecting that the user filter on cstm_description would be combined with the program filter on cstm_pk)
    (I also don't understand why the second request uses AdvancedCriteria, it seems possible with simple criteria?)

    #2
    Did I provide enough information?

    Comment


      #3
      Hi David
      This is odd - I copied your entry point class and datasource definition exactly into my project and am not reproducing this bug. I see simple criteria passed down and the "cstm_pk" : 1 criterion is included along with values I enter into the filter editor.
      Can you try updating to the latest nightly build (available at http://www.smartclient.com/builds) and see if you continue to see the issue.

      If you do let us know the exact version number you're seeing it on (you can get this by evaluating "isc.version" in the developer console window)

      Thanks

      Comment


        #4
        downloaded the latest nightly build, still have the same problem

        developer console:

        SmartClient Version: SC_SNAPSHOT-2010-09-16/PowerEdition Deployment (built 2010-09-16)

        Comment


          #5
          I discovered what is triggering this problem.

          In my testcase I had removed some fields that I thought were not important, but exactly these were causing the problem.

          So if you add this field to your datasource, you will see the error:

          Code:
          <field type="datetime" name="cstm_createdOn" ></field>
          once you have one date or datetime field in your datasource, the problem occurs.

          Comment


            #6
            Ah - that explains why you're seeing advanced criteria being passed down. By default when we show a filter-editor for a date field we show a date-range item (allowing you to select a date range rather than an exact date value to match), which is implemented using advanced criteria.
            It appears there's a bug combining this with the simple criteria you initially specified. We'll take a look at this and let you know when we've got a fix.

            In the meantime a couple of possible workarounds:
            - If you don't care about filtering on the date field, simply set 'canFilter' to false on that field, or if you are ok with the user selecting an exact date rather than a date range, set filterEditor to DateItem
            - Alternatively if you provide your initial criteria as an AdvancedCriteria object rather than a Criteria object the combination when sending criteria to the server should work.

            Comment


              #7
              Ok we've now updated our source code to resolve this issue.
              The fix should be present in the next nightly build.

              Comment

              Working...
              X