![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 4 of 4 total |
![]() |
Thu, Sep 20 2012 1:38 AM | Permanent Link |
Jeff Cook Aspect Systems Ltd | Hi
Using the Trial Version - frantically evaluating EWB before the promo deal expires tomorrow... I composed most of my stuff below before I found this in a post in Febuary:- ===================== - The TGrid component now includes functionality for automatic sorting of datasets by clicking on the column headers. This works with bound grids only. There is also now a public Cells property that allows you to easily get/set any cell using column/row coordinates. ====================== ... BUT I can't see how to set up the sort functionality My code below tries to do the same thing but does some strange things. There are three problems:- 1. My formcreate procedure correctly sorts the data, but doesn't mark the column header with a "^" or "V" like I thought it would. 2. My column header procedure does some odd things (to me). First click on column sorts descending with a "^" mark - I was expecting ascending. Second click sorts ascending with a "v" mark - I was expecting the opposite Third click appears to do nothing except remove the mark on that column. 3. The code to remove the non clicked columns from the sort sequence doesn't work, they just remain marked. The code is below. Cheers Jeff =================================================== procedure TfrmMain.frmMainCreate(Sender: TObject); begin dsOwners.Open; Database.Load(dsOwners); dsOwners.Columns['SortKey'].SortDirection := sdAscending; dsOwners.Sort; end; procedure TfrmMain.grdOwnersColumnHeaderClick(Sender: TObject; Column: TGridColumn); var i: integer; begin // first remove the sort from all but the clicked column for i:= 0 to dsOwners.Columns.Count - 1 do if dsOwners.Columns[i].Name <> Column.DataColumn then dsOwners.Columns[i].SortDirection := sdNone; // for the clicked column, sort ascending unless // already ascending, in which case sort descending if dsOwners.Columns[Column.DataColumn].SortDirection = sdAscending then dsOwners.Columns[Column.DataColumn].SortDirection := sdDescending else dsOwners.Columns[Column.DataColumn].SortDirection := sdAscending; dsOwners.Sort; end; =================================================== |
Mon, Sep 24 2012 1:43 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Jeff,
<< 1. My formcreate procedure correctly sorts the data, but doesn't mark the column header with a "^" or "V" like I thought it would. >> You have to use the grid columns' SortDirection property to make sure that the grid headers change accordingly, like this: Grid1.Columns[1].SortDirection := sdAscending; etc. Currently, the relationship between the grid column's SortDirection property and the dataset is unidirectional, with the grid controlling the process. << 2. My column header procedure does some odd things (to me). First click on column sorts descending with a "^" mark - I was expecting ascending. Second click sorts ascending with a "v" mark - I was expecting the opposite Third click appears to do nothing except remove the mark on that column. >> Yes, ascending is ^, descending is v, and a third click removes any sort at all. << 3. The code to remove the non clicked columns from the sort sequence doesn't work, they just remain marked. >> See above. If you have any other questions, please let me know. Tim Young Elevate Software www.elevatesoft.com |
Mon, Sep 24 2012 2:07 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Jeff,
Just to let you know, since this was an easy fix I've gone ahead and changed it for 1.01. It will automatically have the grid reflect the dataset sort column changes when they occur. This was a basic oversight during 1.00 development that should have been addressed. If you have any other questions, please let me know. Tim Young Elevate Software www.elevatesoft.com |
Mon, Sep 24 2012 4:48 PM | Permanent Link |
Jeff Cook Aspect Systems Ltd | Thanks, Tim
Cheers Jeff |
This web page was last updated on Thursday, March 30, 2023 at 10:19 AM | Privacy Policy![]() © 2023 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |