setDisplayField behaviour

I like the functionality of setDisplayField very, is seems to do some odd things with the search field.

If a listGridField has a setDisplayField set, after a search by manipulating the search field and pressing enter, the datasource of the listGrid is 3(!) times fetched. Why is that? only the last fetch has a filled startRow and endRow in the XML request to the RestDataSource.

The first 2 requests look like this:

<request> 
  <data> 
    <isc_OID_126> 
      <division>searchme</division> 
    </isc_OID_126> 
  </data>  
  <dataSource>isc_OID_126</dataSource>  
  <operationType>fetch</operationType>  
  <operationId>1231711514926</operationId>  
  <startRow/>  
  <endRow/>  
  <sortBy/>  
  <textMatchStyle/>  
  <oldValues/> 
</request>

<request> 
  <data> 
    <isc_OID_126> 
      <division>searchme</division> 
    </isc_OID_126> 
  </data>  
  <dataSource>isc_OID_126</dataSource>  
  <operationType>fetch</operationType>  
  <operationId>1231711515248</operationId>  
  <startRow/>  
  <endRow/>  
  <sortBy/>  
  <textMatchStyle/>  
  <oldValues/> 
</request>

last request:

<request> 
  <data> 
    <isc_OID_126> 
      <division___toString>searchme</division___toString>  
      <division>searchme</division> 
    </isc_OID_126> 
  </data>  
  <dataSource>isc_OID_126</dataSource>  
  <operationType>fetch</operationType>  
  <operationId>1231711515261</operationId>  
  <startRow>0</startRow>  
  <endRow>50</endRow>  
  <sortBy/>  
  <textMatchStyle>substring</textMatchStyle>  
  <componentId>isc_OID_118</componentId>  
  <oldValues/> 
</request>

I assume that this last request comes from the listGrid wanting new filtered data. The other request are (I assume) from the searchField?, maybe it wants to “resolve” the value typed in towards the DisplayField, which is configured for this listGridField. I even use the excellent:

listGridField.setFilterEditorType(new TextItem());

in order to keep the filterField dumb, but no results. (another thing is that it seems that this resolving is done unrestricted! (empty startRow, endRow, see the first 2 requests) which is always wrong IMHO, my datasets are way to large for unrestricted queries)

I all seems that the search field is pretty(/too) smart IMHO (it also gets prefilled with default values f the listgrid field, which I don’t want)

Here are my questions:

  1. Can u explain the multiple request towards the RestDataSource? (this only happens then I set a displayField on the ListGridField)

  2. Can the filter field be made so that it is just a parameter in the request to the datasource. i.e. not a smart field which tries to resolve it’s contents in the case of a set displayField? (I think it should always be manipulated by the user, never by smartgwt)

  3. Can I disable the defaultValue which is set in the filterField when the listGridField has a default value? I do like the defaultValue when a new record is made.

This:

TextItem textItem = new TextItem();
textItem.setDisplayField(null);
textItem.setDefaultValue((String)null);
listGridField.setFilterEditorType(textItem);

in stead of

TextItem textItem = new TextItem();
listGridField.setFilterEditorType(textItem);

changes this behavious in a good way :slight_smile: (the multiple requests of the datasource are gone, and the defaultValue is empty again)

In conclusion, it seems that a newly created(!) TextItem() gets configured heavily by the ListGrid is it used for in a setFilterEditorType() call. IMHO is that not expected behavior, but I can override it so that’s great.

I was a bit to fast with writing that, the multiple request are gone (with the new code) but he default value still appears in the search field.

Hi KingLear,

In SmartClient this would be set via listGridField.defaultFilterValue. Could you add an issue to SmartGWT to add this API?

Added to SVN.

/**

  • If this ListGrid is showing a filter row, this property can be used to apply a default value to show in the filter editor for this field.
  • @param defaultFilterValue the default filter value
    */
    ListGridField.setDefaultFilterValue(…)

Thanks for fixing that, but not quite perfect yet, I’m up to revision 219, and when I:

listGridField.setDefaultValue("def");
listGridField.setDefaultFilterValue("abc");

I see the characters “def” in both a new record AND in the filter field.

Hi Kinglear,
This looks like there’s an underlying SmartClient bug which is causing the default filter values criteria to be unreliable if grids are autoFilter:true.
Setting the initialCriteria should work for you instead for now, and we’ll make sure the underlying issue gets fixed.

Let us know if this doesn’t do it for you

Thanks
Isomorphic Software

Thanks! (I allready made a bug for this: http://code.google.com/p/smartgwt/issues/detail?id=86)

I don’t want to set the initial filter values at all :slight_smile: (which I assume I can do with your work around of setting initialCriteria), I solely want to set default values in some cell’s for a new record. But when I listGridField.setDefaultValue(“def”) both the filterfields and a newrecord-fields get default values. This is not a big thing 4 me, no work around needed, I’ll wait till the bug is fixed.