Difference between revisions of "TDBGridControler"
From Lazarus wiki
Jump to navigationJump to searchLine 9: | Line 9: | ||
− | You need more functionalities? A grid controller that provide extra features to your existing TDBGrid | + | ; You need more functionalities? A grid controller that provide extra features to your existing TDBGrid |
− | * Searching expression in the grid | + | * Searching expression in the grid |
− | * Searching expression in column | + | * Searching expression in column |
− | * Column filter editor | + | * Column filter editor |
− | * Datetime editor, memo editor and lookup editor | + | * Datetime editor, memo editor and lookup editor |
− | * Saving the current filter view | + | * Saving the current filter view |
− | * Multi column sorting | + | * Multi column sorting |
− | * Column chooser editor | + | * Column chooser editor |
− | * Column grouping visual separator on one level | + | * Column grouping visual separator on one level |
− | * Footer and aggregation on columns | + | * Footer and aggregation on columns |
− | TDBGrid Overidden Events to achive the task | + | ; TDBGrid Overidden Events to achive the task |
* OnCellDraw | * OnCellDraw | ||
Line 60: | Line 60: | ||
− | Aggregation example on 2 lines | + | ;Aggregation example on 2 lines |
<syntaxhighlight lang="pascal"> | <syntaxhighlight lang="pascal"> | ||
Line 79: | Line 79: | ||
− | Localization example, french translation of some of the component string resources | + | ;Localization example, french translation of some of the component string resources |
<syntaxhighlight lang="pascal"> | <syntaxhighlight lang="pascal"> | ||
Line 116: | Line 116: | ||
− | Screen shots | + | ;;Screen shots |
[[File:TdxDBGridControler_SearchGrid.png]] | [[File:TdxDBGridControler_SearchGrid.png]] |
Revision as of 22:47, 28 December 2022
TDBGridControler is a non visual component with no dependencies providing added functionalities for the TDBGrid object
Package download link : https://gitlab.com/lazaruscomponent/dbgridcontroler
- 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
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 |
- Aggregation example on 2 lines
Procedure TForm1.dxDBGridControler1Aggregation(Sender: TdxDBGridControler);
Begin
Sender.ColumnPropertyList.ColumnPropertyByName('ProjectManager').FooterAlignment := taRightJustify;
Sender.ColumnPropertyList.ColumnPropertyByName('ProjectManager').FooterDisplayText :=
'Count Distinct : ' + Sender.ColumnPropertyList.Aggregation(agDistinct, 'ProjectManager').AsString;
// Use the FooterPanel property to set the height : dxDBGridControler1.FooterPanel.Height := Self.DBGrid1.DefaultRowHeight * 2;
Sender.ColumnPropertyList.ColumnPropertyByName('OpeningDate').FooterAlignment := taCenter;
Sender.ColumnPropertyList.ColumnPropertyByName('OpeningDate').FooterDisplayText :=
'Min : ' + Sender.ColumnPropertyList.Aggregation(agMin, 'OpeningDate').AsString + Char(13) + Char(10) +
'Max : ' + Sender.ColumnPropertyList.Aggregation(agMax, 'OpeningDate').AsString;
End;
- Localization example, french translation of some of the component string resources
Procedure TForm1.dxDBGridControler1Localize(Sender: TObject; Component: TComponent; ID_Ressource: String; Var Translation: String);
Begin
If ID_Ressource = msg_search Then
Translation := 'Recherche...'
Else If ID_Ressource = msg_first Then
Translation := 'Aller au début'
Else If ID_Ressource = msg_prior Then
Translation := 'Précédent'
Else If ID_Ressource = msg_next Then
Translation := 'Suivant'
Else If ID_Ressource = msg_last Then
Translation := 'Aller à la fin'
Else If ID_Ressource = msg_add Then
Translation := 'Ajouter'
Else If ID_Ressource = msg_delete Then
Translation := 'Détruire'
Else If ID_Ressource = msg_edit Then
Translation := 'Éditer'
Else If ID_Ressource = msg_save Then
Translation := 'Enregistrer'
Else If ID_Ressource = msg_cancel Then
Translation := 'Annuler'
Else If ID_Ressource = msg_refresh Then
Translation := 'Actualiser'
Else If ID_Ressource = msg_btncancel Then
Translation := 'Annuler'
Else If ID_Ressource = msg_of Then
Translation := 'de'
Else If ID_Ressource = msg_nodata Then
Translation := 'Aucune donnée trouvée!';
End;
- Screen shots