TDBGridControler

From Lazarus wiki
Jump to navigationJump to search

TDBGridControler is a non visual component with no dependencies providing added functionalities for the TDBGrid object

Package download link : https://gitlab.com/lazaruscomponent/dbgridcontroler


TdxDBGridController 200.png TDBGridControler component


You need more functionalities? A grid controller that provide extra features to your existing TDBGrid

  • Searching expression in the grid;
  • Searching expression in column;
  • Column filter editor;
  • Datetime editor, memo editor and lookup editor;
  • Saving the current filter view;
  • Multi column sorting;
  • Column chooser editor;
  • Column grouping visual separator on one level;
  • Footer and aggregation on columns;


TDBGrid Overidden Events to achive the task

  • OnCellDraw
  • OnCellHint
  • OnEditorEdit
  • OnMouseClick
  • OnTitleClick
  • OnTitleDraw


TDBGridControler events
OnAfterFilterGrid After filter execution
OnAfterSortColumn After a column is sorted
OnAggregation Define which column is showing an aggregation
OnBeforeSortColumn Before a column is sorted
OnLocalize Use to translate string resources
OnPrepareLookupDataset Use to prepare the lookup dataset
OnSortColumn Custom sort event, could be use to change order by statement in the SQL query


Localization example, french translation of some of the component string resources

 1Procedure TForm1.dxDBGridControler1Localize(Sender: TObject; Component: TComponent; ID_Ressource: String; Var Translation: String);
 2Begin
 3   If ID_Ressource = msg_search Then
 4      Translation := 'Recherche...'
 5   Else If ID_Ressource = msg_first Then
 6      Translation := 'Aller au début'
 7   Else If ID_Ressource = msg_prior Then
 8      Translation := 'Précédent'
 9   Else If ID_Ressource = msg_next Then
10      Translation := 'Suivant'
11   Else If ID_Ressource = msg_last Then
12      Translation := 'Aller à la fin'
13   Else If ID_Ressource = msg_add Then
14      Translation := 'Ajouter'
15   Else If ID_Ressource = msg_delete Then
16      Translation := 'Détruire'
17   Else If ID_Ressource = msg_edit Then
18      Translation := 'Éditer'
19   Else If ID_Ressource = msg_save Then
20      Translation := 'Enregistrer'
21   Else If ID_Ressource = msg_cancel Then
22      Translation := 'Annuler'
23   Else If ID_Ressource = msg_refresh Then
24      Translation := 'Actualiser'
25   Else If ID_Ressource = msg_btncancel Then
26      Translation := 'Annuler'
27   Else If ID_Ressource = msg_of Then
28      Translation := 'de'
29   Else If ID_Ressource = msg_nodata Then
30      Translation := 'Aucune donnée trouvée!';
31End; 
32


Screen shots


TdxDBGridController Properties.png