You are not logged in.
Pages: 1
Hello.
Is there any possibility to show the data on a form using DBGrid? I'm using Turbo Delphi so I'm unable to install any additional VCL components and since it's BDS2006 there aren't any of the Delphi 2009/2010 controls.
Offline
You can not use TDataSet based components with our framework, by design.
But you can use our Grid component in Turbo Delphi, without any problem.
In fact, we don't provide any regular components to be added to your IDE palette.
Our components are created from code only.
This will be definitively 100% Turbo Delphi compatible.
Here are the steps to follow:
1. Put a standard TDrawGrid component on your form;
2. From code, get your table result, in a TSQLTableJSON instance;
3. From code, create a TSQLTableToGrid instance (from unit SQLite3UI) to associate the table with the TDrawGrid;
4. that's all!
Here is the TSQLTableToGrid declaration:
type
/// a hidden component, used for displaying a TSQLTable in a TDrawGrid
// - just call TSQLTableToGrid.Create(Grid,Table) to initiate the association
// - the Table will be released when no longer necessary
// - any former association by TSQLTableToGrid.Create() will be overriden
// - handle unicode, column size, field sort, incremental key lookup, hide ID
// - Ctrl + click on a cell to display its full unicode content
TSQLTableToGrid = class(TComponent)
(....)
/// fill a TDrawGrid with the results contained in a TSQLTable
constructor Create(aOwner: TDrawGrid; aTable: TSQLTable; aClient: TSQLRestClientURI); reintroduce;
/// call this procedure to automaticaly resize the TDrawString columns
// - can be used as TSQLTableToGrid.From(DrawGrid).Resize();
procedure Resize(Sender: TObject);
/// display a popup Hint window at a specified Cell position
// - expect generic string Text, i.e. UnicodeString for Delphi 2009/2010,
// ready to be used with the VCL for all Delphi compiler versions
procedure ShowHintString(const Text: string; ACol, ARow, Time: integer;
FontColor: TColor=clBlack);
/// if the ID column is available, hides it from the grid
procedure IDColumnHide;
/// toggle the sort order of a specified column
procedure SortChange(ACol: integer);
/// set a specified column for sorting
// - if ACol=-1, then the Marked[] rows are shown first, in current sort
procedure SortForce(ACol: integer; Ascending: boolean; ARow: integer=-1);
/// get the ID of the first selected row, 0 on error (no ID field e.g.)
// - usefull even if ID column was hidden with IDColumnHide
function SelectedID: integer;
/// set columns number which must be centered
procedure SetCentered(const Cols: array of cardinal); overload;
/// set a column number which must be centered
procedure SetCentered(aCol: cardinal); overload;
/// force the mean of characters length for every field
// - supply a string with every character value is proportionate to
// the corresponding column width
// - if the character is lowercase, the column is set as centered
// - if aMarkAllowed is set, a first checkbox column is added, for
// reflecting and updating the Marked[] field values e.g.
procedure SetFieldLengthMean(const Lengths: RawUTF8; aMarkAllowed: boolean);
/// force refresh paint of Grid from Table data
// - return true if Table data has been successfully retrieved from Client
// and if data was refreshed because changed since last time
// - if ForceRefresh is TRUE, the Client is not used to retrieve the data,
// which must be already refreshed before this call
function Refresh(ForceRefresh: Boolean=false): boolean;
/// call this procedure after a refresh of the data
// - current Row will be set back to aID
// - called internal by Refresh function above
procedure AfterRefresh(aID: integer);
/// you can call this method when the list is no more on the screen
// - it will hide any pending popup Hint windows, for example
procedure PageChanged;
/// perform the corresponding Mark/Unmark[All] Action
procedure SetMark(aAction: TSQLAction);
/// retrieve the Marked[] bits array
function GetMarkedBits: pointer;
{{ read-only access to a particular row values, as VCL text
- Model is one TSQLModel instance (used to display TRecordReference)
- returns the text as generic string, ready to be displayed via the VCL
after translation, for sftEnumerate, sftTimeLog, sftRecord and all other
properties
- uses OnValueText property Event if defined by caller }
function ExpandRowAsString(Row: integer; Client: TObject): string;
/// retrieve the associated TSQLTableToGrid from a specific TDrawGrid
class function From(Grid: TDrawGrid): TSQLTableToGrid;
/// used by TSQLRestClientURI.UpdateFromServer() to let the client
// perform the rows update (for Marked[])
procedure OnTableUpdate(State: TOnTableUpdateState);
/// associated TDrawGrid
// - just typecast the Owner as TDrawGrid
property DrawGrid: TDrawGrid read GetDrawGrid;
/// associated TSQLTable to be displayed
property Table: TSQLTable read fTable;
/// associated Client used to retrieved the Table data
property Client: TSQLRestClientURI read fClient;
/// used to display some hint text
property Hint: THintWindowDelayed read fHint;
/// assign an event here to customize the background drawing of a cell
property OnDrawCellBackground: TDrawCellEvent read fOnDrawCellBackground
write fOnDrawCellBackground;
/// individual bits of this field is set to display a column data as centered
property Centered: Int64 read fCentered;
/// true if Marked[] is available (add checkboxes at the left side of every row)
property MarkAllowed: boolean read fMarkAllowed;
/// true if any Marked[] is checked
property MarkAvailable: boolean read GetMarkAvailable;
/// true if only one entry is in Marked[], and it is the current one
property MarkedIsOnlyCurrrent: boolean read GetMarkedIsOnlyCurrrent;
/// returns the number of item marked or selected
// - if no item is marked, it return 0 even if a row is currently selected
property MarkedTotalCount: integer read GetMarkedTotalCount;
/// retrieves if a row was previously marked
// - first data row index is 1
property Marked[RowIndex: integer]: boolean read GetMarked write SetMarked;
/// retrieves the index of the sftTimeLog first field
// - i.e. the field index which can be used for Marked actions
// - equals -1 if not such field exists
property FieldIndexTimeLogForMark: integer read GetFieldIndexTimeLogForMark;
/// current field number used for current table sorting
property CurrentFieldOrder: integer read fCurrentFieldOrder;
/// override this event to customize the text display in the table
property OnValueText: TValueTextEvent read fOnValueText write fOnValueText;
/// override this event to customize the Ctrl+Mouse click popup text
property OnHintText: THintTextEvent read fOnHintText write fOnHintText;
/// override this event to customize the Mouse click on a data cell
property OnSelectCell: TSelectCellEvent read fOnSelectCell write fOnSelectCell;
/// override this event to customize the Mouse right click on a data cell
property OnRightClickCell: TRightClickCellEvent read fOnRightClickCell write fOnRightClickCell;
end;
You'll find out that our Grid is much more powerful than the standard DBGrid.
It has integrated sorting, very fast display, is Unicode ready (even previously than Delphi 2009) since the data is UTF-8 stored, automaticaly put CheckBox for booleans, has a more modern layout than the standard Grid, and has incremental search (select the grid, then type some characters on your keyboard: the next matching field will be selected - you can even use soundex search by pressing % before entering the search characters).
Offline
Thanks a lot!
Offline
Pages: 1