Reputation: 545
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
Upvotes: 3
Views: 13319
Reputation: 18061
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
Upvotes: 5