soapsiam
asked on
Click Column to Sort TwwDBGrid Data
This question is specific to Infopower 's TwwDBGrid. In infopower grid, there is no direct property that enable clicking on header column to sort data. We have to set TitleButton to True and write 2 of its event handler. Set Title 's imagelist etc....
If I want to make a component to do this, which is a best solution between:-
1. Inherited from it and add new features to the new component.
2. Make sorting component and link to TwwDBGrid.
I want also a feature like clicking on title column but using hidden data to sort. Multiple column sort using SHIFT key.
If I want to make a component to do this, which is a best solution between:-
1. Inherited from it and add new features to the new component.
2. Make sorting component and link to TwwDBGrid.
I want also a feature like clicking on title column but using hidden data to sort. Multiple column sort using SHIFT key.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I can write event to sort when user click on title button but I have to set many things.
Set Title image list
Write code for OnTitleButtonClick
Write cod for OnCalcTitleAttributes
I have to do this for every form that have a grid. I want to write component that speed up the solution.
//procedure TfrmLineGrantList.wwDBGrid 2TitleButt onClick(Se nder : TObject; AFieldName:String);
procedure OnTitleButtonClick(Sender : TObject; AFieldName:String);
var SortText : String;
DataSet : TCustomADODataSet;
begin
if not (Sender is TwwDBGrid) then exit;
if not (Sender as TwwDBGrid).DataSource.Data Set.Active then exit;
DataSet := ((Sender as TwwDBGrid).DataSource.Data Set) as TCustomADODataSet);
SortText :=DataSet.Sort;
if Pos(AFieldName + ' ASC',SortText)>0 then
SortText := AFieldName + ' DESC'
else
SortText := AFieldName + ' ASC';
DataSet.Sort
end;
TfrmLineGrantList.wwDBGrid 2TitleButt onClick := OnTitleButtonClick;
Above is one of procedure current used for simple sorting (single column).
Set Title image list
Write code for OnTitleButtonClick
Write cod for OnCalcTitleAttributes
I have to do this for every form that have a grid. I want to write component that speed up the solution.
//procedure TfrmLineGrantList.wwDBGrid
procedure OnTitleButtonClick(Sender : TObject; AFieldName:String);
var SortText : String;
DataSet : TCustomADODataSet;
begin
if not (Sender is TwwDBGrid) then exit;
if not (Sender as TwwDBGrid).DataSource.Data
DataSet := ((Sender as TwwDBGrid).DataSource.Data
SortText :=DataSet.Sort;
if Pos(AFieldName + ' ASC',SortText)>0 then
SortText := AFieldName + ' DESC'
else
SortText := AFieldName + ' ASC';
DataSet.Sort
end;
TfrmLineGrantList.wwDBGrid
Above is one of procedure current used for simple sorting (single column).
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The only problem here is responding to a click on the title... I just don't know how to capture that.