Announcement

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

    GetCriteria returns NULL

    Hi. I'm sure I'm missing something obvious, but I can't figure out what. When I add criteria to a grid (whether via ListGrid.getCriteria() or ListGrid.getFilterEditorCriteria()), I always get NULL when I subsequently call the corresponding getCriteria method.

    I have:
    Code:
    public class SmartGWTTestCase implements EntryPoint
    {
    	public void onModuleLoad()
    	{
    
    		if (!GWT.isScript())
    		{
    			KeyIdentifier debugKey = new KeyIdentifier();
    			debugKey.setCtrlKey(true);
    			debugKey.setKeyName("D");
    			Page.registerKey(debugKey, new KeyCallback()
    			{
    				public void execute(String keyName)
    				{
    					SC.showConsole();
    				}
    			});
    		}
    
    		RPCManager.setPromptStyle(PromptStyle.CURSOR);
    		DataSource dataSource = DataSource.get("myds");
    
    		final ListGrid listGrid = new ListGrid();
    		listGrid.setWidth100();
    		listGrid.setHeight100();
    		// listGrid.setAutoFetchData(true);
    		listGrid.setDataSource(dataSource);
    		listGrid.setShowFilterEditor(true);
    		listGrid.setUseAllDataSourceFields(true);
    		ListGridField reportDateField = new ListGridField("reportDate");
    		reportDateField.setFilterEditorType(new DateRangeItem(listGrid, "Report"));
    
    		listGrid.setFields(reportDateField);
    
    		listGrid.draw();
    
    		com.smartgwt.client.data.Criteria c = new com.smartgwt.client.data.Criteria();
    		c.addCriteria("startReportDate", new java.util.Date(0));
    		listGrid.setCriteria(c);
    		SC.say(listGrid.getCriteria() == null ? "null" : "Not null");
    	}
    }
    And, of course, my ds.xml has the following line in it:
    Code:
    		<field name="startReportDate" type="date" hidden="true" customSQL="true"></field>

    #2
    This should be clarified in the docs probably, but, there's no point in calling setCriteria() on a grid before fetchData(). The criteria passed to fetchData() supercede whatever you might have set.

    Comment


      #3
      setFIlterEditorCriteria before a fetchData is sometimes necessary

      GetFilterEditorCriteria return null always, even when I try to get right after setting it using setFIlterEditorCriteria.


      In my case, i'm trying to set a criteria be cause the filter of a listGrid sends a fetch not using a filterData.

      In my case, in which way should handle that automatically sends FetchData when I try to use the filter of a listGrid ?,


      Thanks

      Comment

      Working...
      X