3

I have a strange problem on form: I added a range to filter records in datasource executeQuery() method, this works fine when opening form but if I set manually a filter in the grid header, the range set in ExecuteQuery() method are not applied. My ranges are definied as follow :

this.query.dataSourceNo(1).AddRange(fieldnum(MyTable,MyField)).Value('MyRangeValue');

I use a view as form DataSource, May be it's the problem. Any ideas to always apply ranges and keep it even when manually add filters on grid? Thanks for your help

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
Thomas Post
  • 535
  • 2
  • 11
  • 27

1 Answers1

5

You must apply the filter before the super() in executeQuery().

But I think your problem is you add the filter every time the executeQuery() is run, resulting in an OR in the SQL expression generated.

This is the way to do it:

QueryBuildRange qr = SysQuery::findOrCreateRange(this.query.dataSourceNo(1), fieldnum(MyTable,MyField));
qr.value(queryValue('MyRangeValue'));
qr.status(RangeStatus::Locked); // Or ::Hidden
Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • I tried what you suggested, it doesn't work, I mean my ranges and datasource are OK when I open the form but If I set a filter manually after, the initial ranges doesn't appear and are not used, if I use info(strfmt(this.query().dataSourceNo(1).toString())); exactly the same query is executed : SELECT * FROM OBR_Fact_Fournisseur WHERE ((TaxGroup = N'FIC')), the manual filter doesn't appear inside it but is applied to my datasource. – Thomas Post Jan 23 '13 at 13:20