Announcement

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

    Criteria strange behavior

    I have a strange behavior while using Criteria:

    Everything is normal if I use this:

    Code:
    Criteria c = new Criteria();
    c.addCriteria("schultyp",schultyp);
    fetchData(c);
    The criteria is sent with the DSRequest:

    Code:
    DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{
            schultyp:2
        },
        operationConfig:{
            dataSource:"schuelerSimpleView",
            operationType:"fetch",
            textMatchStyle:"exact"
        },
        startRow:0,
        endRow:75,
        sortBy:[
            "f_name",
            "f_vorname",
            "f_geb_datum"
        ],
        componentId:"isc_SchuelerListGrid_0",
        appID:"builtinApplication",
        operation:"schuelerSimpleView_fetch",
        oldValues:{
            schultyp:2
        }
    }
    So that is the normal behavior: the "schultyp" criteria are sent.

    But if I use this:

    Code:
    Criteria c = new Criteria();
    c.addCriteria("schultyp",schultyp);
    setCriteria( c );
    fetchData();
    the criteria are NOT sent:

    Code:
    Request #1 (DSRequest) payload: {
        criteria:{
        },
        operationConfig:{
            dataSource:"schuelerSimpleView",
            operationType:"fetch",
            textMatchStyle:"exact"
        },
        startRow:0,
        endRow:75,
        sortBy:[
            "f_name",
            "f_vorname",
            "f_geb_datum"
        ],
        componentId:"isc_SchuelerListGrid_0",
        appID:"builtinApplication",
        operation:"schuelerSimpleView_fetch",
        oldValues:{
        }
    Why? Shouldn't it have the same behavior as above?

    I am using SmartGWT 2.5 EE, and my DS is this:

    Code:
    <DataSource
        ID="schuelerSimpleView"
    	serverType="sql"
    	tableName="t_schueler" 
    >
    
        <fields>
        	<field name="f_schueler_id"   type="integer"  primaryKey="true" />
            <field name="f_name"  type="text" required="true" />
            <field name="f_vorname"   type="text"/>
            <field name="f_geb_datum"   type="date" required="true"/>
           	<field name="schultyp" type="integer" />
            
        </fields>
    		
         </operationBindings>
    
    </DataSource>
    I am using the criteria on a class that extends ListGrid

    Thank you

    #2
    That's what fetchData() is documented to do. Pass criteria to it - the absence of criteria means to use no criteria.

    Comment


      #3
      Thanks for your reply.

      In the docs it says:
      "public void fetchData()
      Description copied from interface: DataBoundComponent
      Uses a "fetch" operation on the current DataSource to retrieve data that matches the provided criteria, and displays the matching data in this component. "

      and

      public void setCriteria(Criteria criteria)

      Sets this component's filter criteria. Default implementation calls this.data.setCriteria()

      Isn't the "provided criteria" documented on the fetchData() method the criteria we passed before with setCriteria() ? If not, what is the "provided criteria" in fetchData() (without arguments) ? And what does setCriteria() change in the ListGrid, if not its criteria used for fetching?
      sorry but that is confusing.

      Comment


        #4
        Blank criteria (matches anything).

        Comment

        Working...
        X