Sign in Join
Wiki copytemporary

TdxDBGridController: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## About
22
3-TdxDBGridController is a non visual component with no dependencies providing added functionalities for the TDBGrid object.
3+TdxDBGridController is a non visual component with no dependencies providing added functionalities for the TDBGrid object.
44
55Download: <https://gitlab.com/lazaruscomponent/dbgridcontroller>
66
77Demo project: <https://gitlab.com/lazaruscomponent/dbgridcontroller/-/tree/master/demo>
88
9-Licenses: MPL 2.0 or LGPL.
9+Licenses: MPL 2.0 or LGPL.
1010
11-![\|](/wiki-images/5/5c/TdxDBGridController_200.png) TdxDBGridController component
11+[![TdxDBGridController 200.png](/wiki-images/5/5c/TdxDBGridController_200.png)](</File:TdxDBGridController_200.png>) TdxDBGridController component
1212
13-![](/wiki-images/c/cb/TdxDBGridController_DataControl.png)
13+[![TdxDBGridController DataControl.png](/wiki-images/c/cb/TdxDBGridController_DataControl.png)](</File:TdxDBGridController_DataControl.png>)
1414
15-TdxDBGridController will be installed in the Data Controls tab
15+TdxDBGridController will be installed in the Data Controls tab
1616
1717## Features
1818
1919### Main functionalities
2020
21-A grid controller that provides extra features to your existing TDBGrid.
21+A grid controller that provides extra features to your existing TDBGrid.
2222
23-- Searching expression in the grid
24-- Searching expression in column
25-- Column filter editor
26-- Datetime editor, memo editor and lookup editor
27-- Saving the current filter view (JSON)
28-- Multi column sorting
29-- Column chooser editor
30-- Column grouping visual separator on one level
31-- No data indicator
32-- Footer and aggregation on columns
33-- Perform 50000 records under a second
23+ * Searching expression in the grid
24+ * Searching expression in column
25+ * Column filter editor
26+ * Datetime editor, memo editor and lookup editor
27+ * Saving the current filter view (JSON)
28+ * Multi column sorting
29+ * Column chooser editor
30+ * Column grouping visual separator on one level
31+ * No data indicator
32+ * Footer and aggregation on columns
33+ * Perform 50000 records under a second
3434
3535### TDBGrid events to achive the task
3636
37-For all these events the inherited events are called before they are triggered, it is possible that these cause unexpected behavior, it is therefore necessary to validate the relevance of keeping them or at least validating their execution.
37+For all these events the inherited events are called before they are triggered, it is possible that these cause unexpected behavior, it is therefore necessary to validate the relevance of keeping them or at least validating their execution.
3838
39-- OnDrawColumnTitle
40-- OnDrawColumnCell
41-- OnEditButtonClick
42-- OnGetCellHint
43-- OnKeyDown
44-- OnMouseMove
45-- OnMouseDown
46-- OnTitleClick
39+ * OnDrawColumnTitle
40+ * OnDrawColumnCell
41+ * OnEditButtonClick
42+ * OnGetCellHint
43+ * OnKeyDown
44+ * OnMouseMove
45+ * OnMouseDown
46+ * OnTitleClick
4747
4848### Overriden event of the dataset linked to the TDBGrid
4949
50-If an OnFilterRecord event is used by the dataset, it will be override by the builtin event of the controller, no inheritance is taken into account in this case. Need this to achive the filtering with no interference.
50+If an OnFilterRecord event is used by the dataset, it will be override by the builtin event of the controller, no inheritance is taken into account in this case. Need this to achive the filtering with no interference.
5151
52-- OnFilterRecord
52+ * OnFilterRecord
5353
5454### TdxDBGridController events
5555
56-| | |
57-|----|----|
58-| OnAfterFilterGrid | Event handler triggered after filter execution |
59-| OnAfterSortColumn | Event handler triggered after sorting a column |
60-| OnAggregation | Event handler to define which column is showing an aggregation |
61-| OnBeforeSortColumn | Event handler triggered before sorting a column |
62-| OnLocalize | Event handler triggered to translate string resources |
63-| OnPrepareLookupDataset | Event handler triggered to prepare the lookup dataset if needed |
64-| OnSortColumn | If your dataset is inherited from **TBufDataset**, **TSQLQuery** (Lazarus), **TMSQuery**, **TMSTable** (Devart), **TZQuery**, **TZTable** (ZeosLib) you don't need to use this event handler, the controller will automatically detect the class and set the **IndexDef**, **IndexFieldNames** or **SortedFields** properties accordingly to the dataset you're using. You can use the SQLOrderBy value to requery your dataset on the db server side if needed. |
65-
56+OnAfterFilterGrid | Event handler triggered after filter execution
57+---|---
58+OnAfterSortColumn | Event handler triggered after sorting a column
59+OnAggregation | Event handler to define which column is showing an aggregation
60+OnBeforeSortColumn | Event handler triggered before sorting a column
61+OnLocalize | Event handler triggered to translate string resources
62+OnPrepareLookupDataset | Event handler triggered to prepare the lookup dataset if needed
63+OnSortColumn | If your dataset is inherited from **TBufDataset** , **TSQLQuery** (Lazarus), **TMSQuery** , **TMSTable** (Devart), **TZQuery** , **TZTable** (ZeosLib) you don't need to use this event handler, the controller will automatically detect the class and set the **IndexDef** , **IndexFieldNames** or **SortedFields** properties accordingly to the dataset you're using. You can use the SQLOrderBy value to requery your dataset on the db server side if needed.
64+
6665## Examples
6766
6867### Aggregation example on 2 lines
69-
70-``` pascal
68+```
7169Procedure TForm1.dxDBGridController1Aggregation(Sender: TdxDBGridController);
72-Begin
73- Sender.ColumnPropertyList.ColumnPropertyByName('ProjectManager').FooterAlignment := taRightJustify;
74- Sender.ColumnPropertyList.ColumnPropertyByName('ProjectManager').FooterDisplayText :=
75- 'Count Distinct : ' + Sender.ColumnPropertyList.Aggregation(agDistinct, 'ProjectManager').AsString;
76-
77- // Use the FooterPanel property to set the height : dxDBGridControler1.FooterPanel.Height := Self.DBGrid1.DefaultRowHeight * 2;
78- Sender.ColumnPropertyList.ColumnPropertyByName('OpeningDate').FooterAlignment := taCenter;
79- Sender.ColumnPropertyList.ColumnPropertyByName('OpeningDate').FooterDisplayText :=
80- 'Min : ' + Sender.ColumnPropertyList.Aggregation(agMin, 'OpeningDate').AsString + Char(13) + Char(10) +
81- 'Max : ' + Sender.ColumnPropertyList.Aggregation(agMax, 'OpeningDate').AsString;
82-End;
83-‎
70+ Begin
71+ Sender.ColumnPropertyList.ColumnPropertyByName('ProjectManager').FooterAlignment := taRightJustify;
72+ Sender.ColumnPropertyList.ColumnPropertyByName('ProjectManager').FooterDisplayText :=
73+ 'Count Distinct : ' + Sender.ColumnPropertyList.Aggregation(agDistinct, 'ProjectManager').AsString;
74+
75+ // Use the FooterPanel property to set the height : dxDBGridControler1.FooterPanel.Height := Self.DBGrid1.DefaultRowHeight * 2;
76+ Sender.ColumnPropertyList.ColumnPropertyByName('OpeningDate').FooterAlignment := taCenter;
77+ Sender.ColumnPropertyList.ColumnPropertyByName('OpeningDate').FooterDisplayText :=
78+ 'Min : ' + Sender.ColumnPropertyList.Aggregation(agMin, 'OpeningDate').AsString + Char(13) + Char(10) +
79+ 'Max : ' + Sender.ColumnPropertyList.Aggregation(agMax, 'OpeningDate').AsString;
80+ End;
81+ ‎
8482```
8583
8684### Localization
8785
88-This is an example, French translation of some of the component string resources:
89-
90-``` pascal
86+This is an example, French translation of some of the component string resources:
87+```
9188Procedure TForm1.dxDBGridController1Localize(Sender: TObject; Component: TComponent; ID_Ressource: String; Var Translation: String);
92-Begin
93- If ID_Ressource = msg_search Then
94- Translation := 'Recherche...'
95- Else If ID_Ressource = msg_first Then
96- Translation := 'Aller au début'
97- Else If ID_Ressource = msg_prior Then
98- Translation := 'Précédent'
99- Else If ID_Ressource = msg_next Then
100- Translation := 'Suivant'
101- Else If ID_Ressource = msg_last Then
102- Translation := 'Aller à la fin'
103- Else If ID_Ressource = msg_add Then
104- Translation := 'Ajouter'
105- Else If ID_Ressource = msg_delete Then
106- Translation := 'Détruire'
107- Else If ID_Ressource = msg_edit Then
108- Translation := 'Éditer'
109- Else If ID_Ressource = msg_save Then
110- Translation := 'Enregistrer'
111- Else If ID_Ressource = msg_cancel Then
112- Translation := 'Annuler'
113- Else If ID_Ressource = msg_refresh Then
114- Translation := 'Actualiser'
115- Else If ID_Ressource = msg_btncancel Then
116- Translation := 'Annuler'
117- Else If ID_Ressource = msg_of Then
118- Translation := 'de'
119- Else If ID_Ressource = msg_nodata Then
120- Translation := 'Aucune donnée trouvée!'
121- Else If ID_Ressource = msg_columnchooser Then
122- Translation := 'Sélectionner les colonnes...'
123- Else If ID_Ressource = msg_clearselection Then
124- Translation := 'Annuler sélection'
125- Else If ID_Ressource = msg_selectall Then
126- Translation := 'Tout sélectionner'
127- Else If ID_Ressource = msg_sortingasc Then
128- Translation := 'Trier en mode croissant'
129- Else If ID_Ressource = msg_sortingdesc Then
130- Translation := 'Trier en mode décroissant';
131-End;
132-‎
89+ Begin
90+ If ID_Ressource = msg_search Then
91+ Translation := 'Recherche...'
92+ Else If ID_Ressource = msg_first Then
93+ Translation := 'Aller au début'
94+ Else If ID_Ressource = msg_prior Then
95+ Translation := 'Précédent'
96+ Else If ID_Ressource = msg_next Then
97+ Translation := 'Suivant'
98+ Else If ID_Ressource = msg_last Then
99+ Translation := 'Aller à la fin'
100+ Else If ID_Ressource = msg_add Then
101+ Translation := 'Ajouter'
102+ Else If ID_Ressource = msg_delete Then
103+ Translation := 'Détruire'
104+ Else If ID_Ressource = msg_edit Then
105+ Translation := 'Éditer'
106+ Else If ID_Ressource = msg_save Then
107+ Translation := 'Enregistrer'
108+ Else If ID_Ressource = msg_cancel Then
109+ Translation := 'Annuler'
110+ Else If ID_Ressource = msg_refresh Then
111+ Translation := 'Actualiser'
112+ Else If ID_Ressource = msg_btncancel Then
113+ Translation := 'Annuler'
114+ Else If ID_Ressource = msg_of Then
115+ Translation := 'de'
116+ Else If ID_Ressource = msg_nodata Then
117+ Translation := 'Aucune donnée trouvée!'
118+ Else If ID_Ressource = msg_columnchooser Then
119+ Translation := 'Sélectionner les colonnes...'
120+ Else If ID_Ressource = msg_clearselection Then
121+ Translation := 'Annuler sélection'
122+ Else If ID_Ressource = msg_selectall Then
123+ Translation := 'Tout sélectionner'
124+ Else If ID_Ressource = msg_sortingasc Then
125+ Translation := 'Trier en mode croissant'
126+ Else If ID_Ressource = msg_sortingdesc Then
127+ Translation := 'Trier en mode décroissant';
128+ End;
129+ ‎
133130```
134131
135-List of ressourcestring used by the TdxDBGridController
132+List of ressourcestring used by the TdxDBGridController
136133
137-- msg_search = 'Search...';
138-- msg_first = 'First';
139-- msg_prior = 'Prior';
140-- msg_next = 'Next';
141-- msg_last = 'Last';
142-- msg_add = 'Add';
143-- msg_delete = 'Delete';
144-- msg_edit = 'Edit';
145-- msg_save = 'Save';
146-- msg_cancel = 'Cancel';
147-- msg_refresh = 'Refresh';
148-- msg_btncancel = 'Cancel';
149-- msg_btnok = 'OK';
150-- msg_of = 'of';
151-- msg_nodata = 'No Data Found!';
152-- msg_columnchooser = 'Column Chooser...';
153-- msg_clearselection = 'Clear Selection';
154-- msg_selectall = 'Select All';
155-- msg_sortingasc = 'Sort by ascending order';
156-- msg_sortingdesc = 'Sort by descending order';
134+
157135
136+ * msg_search = 'Search...';
137+ * msg_first = 'First';
138+ * msg_prior = 'Prior';
139+ * msg_next = 'Next';
140+ * msg_last = 'Last';
141+ * msg_add = 'Add';
142+ * msg_delete = 'Delete';
143+ * msg_edit = 'Edit';
144+ * msg_save = 'Save';
145+ * msg_cancel = 'Cancel';
146+ * msg_refresh = 'Refresh';
147+ * msg_btncancel = 'Cancel';
148+ * msg_btnok = 'OK';
149+ * msg_of = 'of';
150+ * msg_nodata = 'No Data Found!';
151+ * msg_columnchooser = 'Column Chooser...';
152+ * msg_clearselection = 'Clear Selection';
153+ * msg_selectall = 'Select All';
154+ * msg_sortingasc = 'Sort by ascending order';
155+ * msg_sortingdesc = 'Sort by descending order';
156+
158157## Screenshots
159158
160159### Global search
161160
162-![](/wiki-images/7/75/TdxDBGridController_SearchGrid.png)
161+[![TdxDBGridController SearchGrid.png](/wiki-images/7/75/TdxDBGridController_SearchGrid.png)](</File:TdxDBGridController_SearchGrid.png>)
163162
164163### Multi sort
165164
166-A Ctrl+Left clic is use to performe a multi column sorting, the index will appear under the sort indicator.
165+A Ctrl+Left clic is use to performe a multi column sorting, the index will appear under the sort indicator.
167166
168-![](/wiki-images/1/13/TdxDBGridController_MultiSort.png)
167+[![TdxDBGridController MultiSort.png](/wiki-images/1/13/TdxDBGridController_MultiSort.png)](</File:TdxDBGridController_MultiSort.png>)
169168
170169### Column filter
171170
172-Once you have focused on the grid you can have access to the column filter by clicking the filter icon or with the default shortcut Ctrl+J, this shortcut could be changed with the ColumnFilterShortCut property.
171+Once you have focused on the grid you can have access to the column filter by clicking the filter icon or with the default shortcut Ctrl+J, this shortcut could be changed with the ColumnFilterShortCut property.
173172
174-![](/wiki-images/1/1b/TdxDBGridController_ColumnFilter.png)
173+[![TdxDBGridController ColumnFilter.png](/wiki-images/1/1b/TdxDBGridController_ColumnFilter.png)](</File:TdxDBGridController_ColumnFilter.png>)
175174
176175### Column search and aggregation
177176
178-It is not mandatory to use the footer panel to display the aggregation, you can use any other control at your convenience. The values are calculated and set in the OnAggregation event. In this example, the FooterPanel height of the TdxDBGridController was set to Self.DBGrid1.DefaultRowHeight * 2 in order to display the result on 2 lines.
177+It is not mandatory to use the footer panel to display the aggregation, you can use any other control at your convenience. The values are calculated and set in the OnAggregation event. In this example, the FooterPanel height of the TdxDBGridController was set to Self.DBGrid1.DefaultRowHeight * 2 in order to display the result on 2 lines.
179178
180-![](/wiki-images/c/cc/TdxDBGridController_SearchAndAggregation.png)
179+[![TdxDBGridController SearchAndAggregation.png](/wiki-images/c/cc/TdxDBGridController_SearchAndAggregation.png)](</File:TdxDBGridController_SearchAndAggregation.png>)
181180
182181### TdxDBGridController properties
183182
184-![](/wiki-images/6/6c/TdxDBGridController_Properties.png)
183+[![TdxDBGridController Properties.png](/wiki-images/6/6c/TdxDBGridController_Properties.png)](</File:TdxDBGridController_Properties.png>)
185184
186185# See also
187186
188-- [[doc:lcl/dbgrids/tdbgrid.html|TDBGrid doc]]
189-- [[TDBGrid]]
190-- [[TStringGrid]]
191-- [[Grids Reference Page]]
187+ * [TDBGrid doc](<http://lazarus-ccr.sourceforge.net/docs/lcl/dbgrids/tdbgrid.html> "doc:lcl/dbgrids/tdbgrid.html")
188+ * [[TDBGrid]]
189+ * [[TStringGrid]]
190+ * [[Grids Reference Page]]
192191
193192---
194-*From the Free Pascal wiki, page "TdxDBGridController", as it stood on 2023-01-23 after a change by Five, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
193+*From the Free Pascal wiki, page "TdxDBGridController", as the Internet Archive kept it on 2025-01-14, last changed on 2024-08-07. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history