Two question on visual aspect (Checkboxes and Sort arrow)...

TeeGrid VCL / FMX for Embarcadero RAD Studio, Delphi, C++ Builder and Lazarus Free Pascal.
Post Reply
Jonsafi
Newbie
Newbie
Posts: 9
Joined: Tue Jul 14, 2020 12:00 am

Two question on visual aspect (Checkboxes and Sort arrow)...

Post by Jonsafi » Fri Jul 24, 2020 7:42 am

Hello,

Am just getting the hang of the very versatile and impressive TeeGrid. Having
checkboxes is a great addition; and as I understand, they are created as a
separate column (not to be combined with an existing one).
Was able to get the checkboxes to appear using:

Code: Select all

MyTeeGrid.Columns[MyColumn].Render    := TBooleanRender.Create
but then couldn't find an example for VLC on how to catch and process the user's choices...

Another question related to visual aspects came up with sorting. Since am using
TVirtualModeData (which I presume is so fast because it gets the
data from the given source using GetData only when it needs to display it),
am doing the sorting externally, and then re-sending the data (kind of as a result of a new query)
to be displayed. Noticed that there are methods to get the little upward/downward
pointing arrow to be displayed, but could not get a downward pointing arrow
(for Descending) to be displayed.

The code is as follows (_g at end of variable indicates globality)

My obliged for your comments and kind help.
Regards, Sami.

Code: Select all

Procedure display_grid;
BEGIN
Data_tee_G       := TVirtualModeData.Create(
                                                 Nr_Cols_G,Nr_Rows_G,60);
MyTeeGrid.Header.SortRender            := TSortableHeader.Create(MyTeeGrid.Header.Changed);
MyTeeGrid.Header.SortRender           := CreateSortable; // will only use this to display sorting arrow
Data_tee_G.OnGetValue                     := GetCell; 
MyTeeGrid.Data                                 := Data_tee_G; // bind virtual data
MyTeeGrid.Header.Sortable                := True;
END;

procedure TMyForm.TeeGridClickedHeader(Sender: TObject);
Var
is_ascending:Boolean;
cur_tc:TColumn;
cur_tc_i:SmallInt;
BEGIN
cur_tc     :=    (Sender as TColumn); // current column to be sorted
cur_tc_i  :=    (cur_tc).Index; 


If sorted_col_status_g[cur_tc_i] = -1 Then // keep a global for the direction of each sorted column
  is_ascending := True
Else
is_ascending := False;

Data_tee_G.IsSorted(cur_tc,is_ascending); // try to set variable 'is_ascending'

// do the external sorting routine here (not shown)
// provide the grid with the new, sorted data.
display_grid;   // populate grid with new sorted data.
END;

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Two question on visual aspect (Checkboxes and Sort arrow)...

Post by Yeray » Wed Jul 29, 2020 7:11 am

Hello,
Jonsafi wrote:
Fri Jul 24, 2020 7:42 am
couldn't find an example for VLC on how to catch and process the user's choices...
The example here uses the OnCellEdited event to catch the changes.
Jonsafi wrote:
Fri Jul 24, 2020 7:42 am
Another question related to visual aspects came up with sorting. Since am using
TVirtualModeData (which I presume is so fast because it gets the
data from the given source using GetData only when it needs to display it),
am doing the sorting externally, and then re-sending the data (kind of as a result of a new query)
to be displayed. Noticed that there are methods to get the little upward/downward
pointing arrow to be displayed, but could not get a downward pointing arrow
(for Descending) to be displayed.
Take a look at the example here where we are sorting the values and both arrows seem to be correctly displayed.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Jonsafi
Newbie
Newbie
Posts: 9
Joined: Tue Jul 14, 2020 12:00 am

Re: Two question on visual aspect (Checkboxes and Sort arrow)...

Post by Jonsafi » Wed Jul 29, 2020 2:50 pm

Yeray wrote:
Wed Jul 29, 2020 7:11 am
Hello,
Jonsafi wrote:
Fri Jul 24, 2020 7:42 am
couldn't find an example for VLC on how to catch and process the user's choices...
The example here uses the OnCellEdited event to catch the changes.
Jonsafi wrote:
Fri Jul 24, 2020 7:42 am
Another question related to visual aspects came up with sorting. Since am using
TVirtualModeData (which I presume is so fast because it gets the
data from the given source using GetData only when it needs to display it),
am doing the sorting externally, and then re-sending the data (kind of as a result of a new query)
to be displayed. Noticed that there are methods to get the little upward/downward
pointing arrow to be displayed, but could not get a downward pointing arrow
(for Descending) to be displayed.
Take a look at the example here where we are sorting the values and both arrows seem to be correctly displayed.
Hello,
Thanks for your helpful reply. Regarding sorting, I did have a look at the nice sorting example you mentioned,
but my case is a bit out of the ordinary as am not using the Teegrid properties for sorting, am
doing the sorting stuff externally and just 'pumping' the sorted data into the grid..all I need is to call separately
the procedure for displaying the downward pointing arrow, to show the user the current sorted status...
is this possible..?

Kind regards.

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Two question on visual aspect (Checkboxes and Sort arrow)...

Post by Yeray » Thu Jul 30, 2020 9:08 am

Hello,

I still think the easiest would be to use the TSortableHeader class. In your case you'd only need to use the OnSortState event from it so it can draw the arrow in the correct direction according to your external sorting.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply