Documents
NextGrid & NextDBGrid
- Html Column Tutorial
- Upgrade existing projects for loading changes
- Edit events in NextGrid
- NextGrid Vista Style
- NextGrid How To
- Integrating Inplace Editors
- NextGrid Slide Style Tutorial
- InputLine Tutorial
- FieldChooser Tutorial
- Using Editors in runtime
- Grid Report Tutorial
NextGrid
- TreeColumn Tutorial
- NextGrid Quick Start
- Custom Draw in NextGrid
- Export to XML from NextGrid
- Optimize NextGrid
- NextGrid Custom Sorting
- VirtualColumn Tutorial
- Graphic Column Tutorial
NextDBGrid
- NextDBGrid Quick Start
- NextDBGrid Events
- NextDBGrid How To
- Sorting records in NextDBGrid
- LookupColumn Tutorial
NextInspector
- NextInspector Advanced tutorial
- ToolbarItem tutorial
- NextDBInspector Tutorial
- NextInspector Item Types
- Map VCL property to item
- NextInspector Quick Start
NextSheet
NextCollection
- NxAlertWindow Tutorial
- NxInfoPanel Tutorial
- Vista Styled Panels
- NxPathControl and NxNotebook tutorial
- NxPathControl Quick Start
- NxFlipPanel and NxHeaderPanel Quick Start
- NxOutlookBar Tutorial
- NxPageControl and NxNotebook Quick Start
- NxButton Tutorial
Misc
- Component Names Change
- NxComboBox styles
- Numeric FormatMask
- NxVirtualDataSet tutorial
- DateTime FormatMask
- NxPreview Quick Start
- 32bit Bitmaps Tutorial
- Quick update
- Enable typing unicode characters in InplaceEditors
- Using NxColorScheme
- NxProgress Tutorial
- NxAutoCompletion Tutorial
Labs
NextGrid .NET
Sorting records in NextDBGrid
Related Articles:
Info
- Skill:
- Version: 1.0.0
- Author: Bojan Nikolic
- Created: 2009-02-26
- Updated: 2009-02-26
NextDBGrid does't have integrated sorting routine like NextGrid. To sort data, NextDBGrid get help from DataSet. Adding sorting capabilities to DBGrid is very easy, but may be different for some protocols when working with Tables (not Queries).
Implementing Sorting Routine
For adding sort capability to NextDBGrid, following code need to be added to OnSortColumn event:
Sorting Query
procedure TForm1.NextDBGrid1SortColumn(Sender: TObject; ACol: Integer; Ascending: Boolean); var DirectionStr: string; QueryString: string; begin QueryString := 'SELECT * FROM EMPLOYEE'; // Query statement if NextDBGrid1.Columns[ACol].FieldName = '' then Exit; if Ascending then DirectionStr := 'ASC' else DirectionStr := 'DESC'; Query1.SQL.Text := QueryString ' ORDER BY ' NextDBGrid1.Columns[ACol].FieldName ' ' DirectionStr; Query1.Open; end;
Sorting ADO Table
procedure TForm1.NextDBGrid1SortColumn(Sender: TObject; ACol: Integer; Ascending: Boolean); var DirectionStr: string; begin if NextDBGrid1.Columns[ACol].FieldName = '' then Exit; if Ascending then DirectionStr := 'ASC' else DirectionStr := 'DESC'; ADOTable1.Sort := NextDBGrid1.Columns[ACol].FieldName ' ' DirectionStr; ADOTable1.Active := True; end;
Comments
2010-09-15 07:11:37
can i sort by two columns same time?
for example, 3 columns date,item name, value1,valuen....
sorting every column after date, it sorts first by selected column and then same time by date descending?
for example, 3 columns date,item name, value1,valuen....
sorting every column after date, it sorts first by selected column and then same time by date descending?
2010-09-15 12:10:20
Hello,
Unfortunately this is not possible at the moment.
Best regards
Unfortunately this is not possible at the moment.
Best regards