Announcement

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

    grid.setFilterEditorCriteria with boolean/checkbox field not working

    Hello, using SmartGWT Power Nightly of 2013-01-09.

    I have a ListGrid with showFilterEditor true, and i want to automatically check a checkbox in a boolean field, to only show non-archived records.
    Like so:
    Code:
    AdvancedCriteria crit = new AdvancedCriteria(new Criterion("teacherArchived", OperatorId.EQUALS, false));
    grid.setFilterEditorCriteria(crit);
    grid.filterByEditor();
    this does not seem to work. In contrast, when doing something similar in a date field, for instance, where I'd preset a dateRange, it DOES work.

    Is this on purpose, or is this a bug, or am I doing something wrong here?

    #2
    Which version of SmartGWT are you using? Evaluate isc.version in your browser console

    Comment


      #3
      Some quick tests seem to show that boolean filtering in this fashion works as expected.

      Can you confirm what you expect to see vs what you do see? You say that you "want to automatically check a checkbox", but your code will automatically UNcheck the checkbox, and that seems to be what you want, from your description, right?

      Comment


        #4
        and that seems to be what you want, from your description, right?
        Yes, my bad. I meant as per the description

        I am using:SmartClient Version: v8.3p_2013-01-09/PowerEdition Deployment (built 2013-01-09)


        Ok what happens is, it shows me ALL rows, ie. it's NOT applying the unchecked boolean filter.

        It _should_ show only rows that have that field set to 'false'.

        Logs confirm also that the DSRequest body does not contain the criteria teacherArchived=false, thus it should be a client-side problem.

        Lastly, to confirm that my listgrid was setup properly, I used my mouse to toggle between check/uncheck/all-mode in the boolean listgrid filter editor of the field teacherArchived, and upon doing that the criteria _were_ sent to the server (and thus eventually applied as criteria to some mysql query.

        Comment


          #5
          We don't see this against latest 3.1 - the code you showed correctly applies the boolean criteria in our tests.

          Are you calling it before draw()? If so, use initialCriteria instead.

          If not, we may need to see a standalone test case that shows the issue - in the meantime, can you show the dataSource?

          Ultimately, if there *is* a problem in the framework, you're going to have to update to the latest build from smartclient.com/builds, so it's worth trying that now anyway.
          Last edited by Isomorphic; 8 Oct 2014, 23:58.

          Comment


            #6
            Yeah I will do that anyway. But last time I had a different problem with that.

            But I am calling it before draw. But I also did that with some other situation where I set the filter editor to hold a certain date range in a date field of a listgrid. And there it worked... so i figured this should too.

            Now I also tried to run the code AFTER the grid was added to a VLayout container (is that what you mean with 'after draw()'?

            This didn't solve it too, so I will now try the latest nightly.


            As an aside: now that firefox out-updates the GWT plugin, what browser do you recommend to develop in? An older Firefox ? (OSX here)

            Comment


              #7
              I tried with latest nightly, of 3.1, but to no avail.

              I tried both doing this before draw (As i had it) and after adding the grid to a VLayout container.

              Is that the way it should?

              Here is my datasource by the way, the teacherArchived field is somewhere half way:
              Code:
              <DataSource ID="Teacher" serverType="sql" tableName="Teacher"> 
                <fields> 
                  <!-- Id, with primaryKey -->  
                  <field name="Teacher_id" type="sequence" primaryKey="true"/>  
                  <!-- This is a SaaS solution, so, every ds.xml has a SaasCustomer_id foreign key -->  
                  <field name="SaasCustomer_id" type="integer" foreignKey="saasCustomers.SaasCustomer_id"/>  
                  <!-- Attributes -->  
                  <field name="firstname" type="text" required="false" length="128"> 
                    <title>firstname</title>  
                    <validators></validators> 
                  </field>  
                  <field name="tussenvoegsel" type="text" required="false" length="128"> 
                    <title>tussenvoegsel</title>  
                    <validators></validators> 
                  </field>  
                  <field name="surname" type="text" required="false" length="128"> 
                    <title>surname</title>  
                    <validators></validators> 
                  </field>  
                  <field name="street" type="text" required="false" length="128"> 
                    <title>street</title>  
                    <validators></validators> 
                  </field>  
                  <field name="number" type="integer" required="false"> 
                    <title>number</title>  
                    <validators></validators> 
                  </field>  
                  <field name="number_addition" type="text" required="false" length="3"> 
                    <title>number_addition</title>  
                    <validators></validators> 
                  </field>  
                  <field name="postcode" type="text" required="false" length="7"> 
                    <title>postcode</title>  
                    <validators></validators> 
                  </field>  
                  <field name="city" type="text" required="false" length="128"> 
                    <title>city</title>  
                    <validators></validators> 
                  </field>  
                  <field name="country" type="text" required="false" length="128"> 
                    <title>country</title>  
                    <validators></validators> 
                  </field>  
                  <field name="homePhone" type="text" required="false" length="128"> 
                    <title>homePhone</title>  
                    <validators></validators> 
                  </field>  
                  <field name="phone" type="text" required="false" length="128"> 
                    <title>phone</title>  
                    <validators></validators> 
                  </field>  
                  <field name="email" type="text" required="false" length="128"> 
                    <title>email</title>  
                    <validators></validators> 
                  </field>  
                  <field name="type" type="enum" required="true"> 
                    <title>type</title>  
                    <valueMap> 
                      <value>externe opleider</value>  
                      <value>freelancer</value>  
                      <value>intern</value> 
                    </valueMap>  
                    <validators></validators> 
                  </field>  
                  <field name="teacherArchived" type="boolean" required="false"> 
                    <title>teacherArchived</title>  
                    <validators></validators> 
                  </field>  
                  <field name="hourlyrate" type="float" required="false"> 
                    <title>hourlyrate</title>  
                    <validators></validators> 
                  </field>  
                  <field name="companyName" type="text" required="false" length="128"> 
                    <title>companyName</title>  
                    <validators></validators> 
                  </field>  
                  <field name="companyStreet" type="text" required="false" length="128"> 
                    <title>companyStreet</title>  
                    <validators></validators> 
                  </field>  
                  <field name="companyZipcode" type="text" required="false" length="128"> 
                    <title>companyZipcode</title>  
                    <validators></validators> 
                  </field>  
                  <field name="companyCity" type="text" required="false" length="128"> 
                    <title>companyCity</title>  
                    <validators></validators> 
                  </field>  
                  <field name="availability" type="text" required="false" length="128"> 
                    <title>availability</title>  
                    <validators></validators> 
                  </field>  
              
                  <field name="userAccount" type="text" required="false"/>  
                  <field name="CourseEdition_id" type="integer" tableName="CourseEdition" customSQL="true"/>  
                </fields>  
                <operationBindings> 
                  <operationBinding operationType="add" requiresAuthentication="true" requiresRole="CAN_CREATE_TEACHER"> 
                  </operationBinding>  
                  <operationBinding operationType="fetch" requiresAuthentication="true" requiresRole="CAN_READ_TEACHER"> 
                    <selectClause>$defaultSelectClause, (users.username IS NOT NULL) as userAccount</selectClause>  
                    <tableClause>Teacher LEFT OUTER JOIN users ON Teacher.Teacher_id = users.Teacher_id</tableClause>  
                  </operationBinding>  
                </operationBindings>
              </DataSource>
              also: visually it's not showing an empty square in the header, but one with a gray square in it.
              Last edited by Sytematic; 9 Oct 2014, 01:13.

              Comment


                #8
                We're still not reproducing any issue here, so we'll need to see a standalone test case that shows how it comes about in order to help - self-contained code that we can drop into a project - so, setup and data spec (including clientOnly dataSources if your sample requires dataSources).

                Comment


                  #9
                  Alright fair enough, I will work on this.

                  Comment


                    #10
                    I've made a test case, using the nightly of Power edition of the 9th of October 2014.:

                    the main method:
                    Code:
                    public void onModuleLoad() {
                    	TempListGrid grid = new TempListGrid();
                    	grid.show();
                    }
                    The grid:
                    Code:
                    public class TempListGrid extends ListGrid {
                    	
                    	public TempListGrid(){
                    		DataSource dataSource = new DataSource();
                    		dataSource.setID("supplyItemDS");
                    		dataSource.setRecordXPath("/List/supplyItem");
                    		DataSourceField idField = new DataSourceField("id", FieldType.INTEGER, "Id");
                    		DataSourceField booleanField = new DataSourceField("boolean", FieldType.BOOLEAN, "Boolean");
                    		dataSource.setFields(idField,booleanField);
                    		dataSource.setDataURL("ds/test_data/supplyItem.data.xml");
                    		dataSource.setClientOnly(true);
                    		
                    		setDataSource(dataSource);
                    		setAutoFetchData(true);
                    		setShowFilterEditor(true);
                    		setWidth(500);
                    		setHeight(300);
                    		AdvancedCriteria crit = new AdvancedCriteria(new Criterion("boolean", OperatorId.EQUALS, true));
                    		setFields(new ListGridField("id"), new ListGridField("boolean"));
                    		setFilterEditorCriteria(crit);
                    		filterByEditor();
                    	}
                    }
                    Test data for clientOnly data source, put in /ds/test_data/supplyItem.data.xml:
                    Code:
                     
                    <List>  
                    <supplyItem>  
                        <id>1</id>  
                        <boolean>true</boolean>  
                    </supplyItem>  
                    <supplyItem>  
                        <id>2</id>  
                        <boolean>false</boolean>  
                    </supplyItem>  
                    <supplyItem>  
                        <id>3</id>  
                        <boolean>true</boolean>  
                    </supplyItem>  
                    <supplyItem>  
                        <id>4</id>  
                        <boolean>false</boolean>  
                    </supplyItem>  
                    </List>
                    I would expect the filter to automatically set the filter with the checkmark ON, in this case, and then only show record ID's 1 and 3.
                    It doesn't populate the filter editor at all however, and keeps showing all records.
                    Last edited by Sytematic; 27 Oct 2014, 08:22.

                    Comment


                      #11
                      Ok, if I modify the above testcase in one of the two ways, it DOES work, so this is a pretty big insight in what might be going wrong in my large web-app:

                      1) call grid.filterByEditor() after grid.show()
                      2) OR use grid.setInitialCriteria() it works.

                      I don't have time right now to check why it doesn't work in my case with setInitialCriteria(), but it does seem that has something to do with it.

                      I will try some stuff myself first thing in the morning tomorrow (GMT+1 here), since this testcase gave me some insights.

                      If it doesn't work out I might head back here.

                      (Also, great way to create a small test cases, using the clientOnly data sources, hadn't tried that before.)

                      Comment


                        #12
                        A new insight is that it DOES work when using autoFetchData(true), combined with initialCriteria.

                        However, I cannot really use autoFetchData, so I'm looking for something that works without it.

                        Any ideas, is there any callback i can register, that 'll make it work?

                        Comment


                          #13
                          We've fixed this - it was a bug arising as a result of calling setFilterEditorCriteria() before draw.

                          You can retest with a build of 5.0 dated November 6 or later.

                          In the meantime, you can just call setCriteria() instead of calling both setFilterEditorCriteria() and filterByEditor().

                          Comment

                          Working...
                          X