Announcement

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

    Criterion object and ListGrid fetch

    I'm using a SQL data source in the EE eval version (SmartClient Version: SC_SNAPSHOT-2010-06-25/EVAL ). I have a simple sql data source xml file defined with just field entries. I'm trying to set criteria for the fetch to ignore null values in two of the fields. I have created a Criterion object and added two criteria entries using OperatorId.IS_NULL with a boolean value of false. Next is a call to fetch( criteria ) on the ListGrid using the Criterion object. The result is that all rows are retrieved and the filter criteria is ignored. Along the way there is a log entry that says:

    setProperties: couldn't set:
    {
    context:"No such property"
    }

    When I use a Criteria object, the filtering works (but the setProperties error is still there?) The Criteria object doesn't provide for filtering out null values through. If I'm missing something please advise. This will be deployed in a Pro environment so Custom SQL is not an option (I had set up a WHERE clause in the original of this data source which worked correctly). I can work around this with a custom data source object and apply the required filtering using SQL - but hopefully that won't be necessary as it defeats the simplicity of the built-in datasource.

    #2
    Wouldn't worry about the setProperties() warning. What we'd need to see is the code for putting the criteria together, what it looks like in the server logs and the generated SQL (also in the server logs).

    Comment


      #3
      I'm extending the built-in-ds sample. The code for the data source:

      Code:
      <DataSource ID="testDatasource" 
           serverType="sql" 
           tableName="testTable">
          <fields>
              <field name="field1" type="text" length="20" title="Field 1"/>
              <field name="field2" type="text" length="10" title="Field 2" primaryKey="true"/>
              <field name="field3" type="text" length="15" title="Field 3"/>
              <field name="field4" type="text" length="5" title="Field 4"/>
              <field name="field5" type="date" title="Field 5"/>
              <field name="field6" type="date" title="Field 6"/>
          </fields>
      </DataSource>
      I've replaced the actual table name and field names above but the properties are the same as the "real" data source.

      The code to set up the Criterion is this:

      Code:
      import com.smartgwt.client.data.Criterion;
      
            Criterion criterion = new Criterion();
      
            criterion.addCriteria( "field4", OperatorId.IS_NULL, new Boolean( false ) );
            criterion.addCriteria( "field5", OperatorId.IS_NULL, new Boolean( false ) );
      
      
            DataSource ds = DataSource.get( dsName );
            boundList.setDataSource( ds );
            boundViewer.setDataSource( ds );
            boundForm.setDataSource( ds );
            boundList.fetchData( criterion );
      I've attached the tomcat log, again replacing identifiers to keep the data anonymous.
      Attached Files

      Comment


        #4
        Pro supports only simple Criteria and no SQL Templating. Power supports both. Here you're passing AdvancedCriteria, but due to the lack of support they're just being interpreted as simple Criteria, so you end up with a where clause that selects everything.

        Really, we'd recommend an upgrade to Power here. In general, if you're going to be relying on our SQL connector, you'll want the features of Power again and again. Note you're allowed to upgrade by just paying the difference.

        Comment


          #5
          Hi

          I am using an advancedfilter (nested) to filter a ListGrid. I am only using the client (v8 LGPL, Nov11-2010 build) with a PHP backend. When I do a simple AND filter on 2 fields, the GET variable on my PHP backend only has the last field (no signs of the first field to filter), thus I'm unable to carry out the filtering on the backend.

          Is this because I am using the LGPL version and multiple fields filtering is not supported, or am I missing something?

          I am using Chrome and Firefox 3 browsers. My code is as follows:

          Code:
          <script> 
           
                      isc.RestDataSource.create({
                          ID:"DS_responses",
                          dataFormat:"json",
                          fields:[
                              {name:"docId", title:"Response Id",}
          ,{name:"72bfc36a3e48cb54977fd57090a833af", title:"Date", type: "date"}
          ,{name:"04e1b5038c95518a7d9fd2736bfa1d6d", title:"Hours", type: "integer"}
          ,{name:"ae39334257e9227eabbe73f75429536c", title:"Project"}
          ,{name:"986252575b8a0dfae533d168fc437fca", title:"Manager", canSort: false}                ],
                          fetchDataURL:"<url goes here>",
                          dataPageSize: 5
                      });
           
                      isc.FilterBuilder.create({
                          ID:"advancedFilter",
                          dataSource:"DS_responses"
                      });
           
                      isc.IButton.create({
                          ID:"filterButton",
                          title:"Filter",
                          click : function () {
                              responses_list.filterData(advancedFilter.getCriteria());
                          }
                      });
           
                      isc.ListGrid.create({
                          ID: "responses_list",
                          width:550, height:124, alternateRecordStyles:true,
                          dataSource: "DS_responses",
                          dataPageSize: 5,
                          drawAheadRatio: 1,
                          showAllRecords:false,
                          autoFetchData: true
                      });
           
                    
                      isc.VLayout.create({
                          position: "relative",
                          membersMargin:10,
                          members:[ advancedFilter, filterButton, responses_list ]
                      });
           
                </script>
          Many thanks in advance

          Comment

          Working...
          X