Delphi & C++ Builder components library
and Software development

rDBGrid - how to implement filtering functions

All filtering functions in rDBGrid and rDBFilter use local filter for linked dataset (property Filter and Filtered). Properties are same for all dataset type but there could be differencies in wildcard char used for filtering by text part only. Therefore wildcard has to be configured according to used dataset.

There is prepared configuration in RosiCompGlobalCfg unit which contains default setting for filtering which is valid for most of datasets:

  • RosiCompConfig.rDBFilterCfg.FilterWildCardChar:='*';
  • RosiCompConfig.rDBFilterCfg.SQLWildCardChar:='%';
  • RosiCompConfig.rDBFilterCfg.FilterLikeOperator:='LIKE';
  • RosiCompConfig.rDBFilterCfg.SQLLikeOperator:='LIKE';
  • RosiCompConfig.rDBFilterCfg.NullEqualStr:='=';
  • RosiCompConfig.rDBFilterCfg.DateFormat:='';
  • RosiCompConfig.rDBFilterCfg.BooleanString[true]:='true';
  • RosiCompConfig.rDBFilterCfg.BooleanString[false]:='false';
  • RosiCompConfig.rDBFilterCfg.TableQuoteStart:='[';
  • RosiCompConfig.rDBFilterCfg.TableQuoteStop:=']';
  • RosiCompConfig.rDBFilterCfg.FieldQuoteStart:='[';
  • RosiCompConfig.rDBFilterCfg.FieldQuoteStop:=']';
  • RosiCompConfig.rDBFilterCfg.ShowDelQuotes:=false;
  • RosiCompConfig.rDBFilterCfg.ShowCaseSensitive:=true;
  • RosiCompConfig.rDBFilterCfg.HideFieldNames:=false;
  • RosiCompConfig.rDBFilterCfg.DecimalSeparator:='.';

If another setting is needed, it can be done easily by setting of another value to this configuration, ideally in the OnCreate event of the main form.

Example: FireDac with MySQL uses % as filter wildcard. So following code is needed:

  • uses RosiCompGlobalCfg;
  • RosiCompConfig.rDBFilterCfg.FilterWildCardChar:='%'

It can be configured also for one particular rDBGrid by property OptionsEx2.Filters.TextFilterLikeChar and TextFilterLikeOperator.

Go back