Unit Gridutil

Classes

TDlgColumnVisible -

Functions

CopyGridLayout - CopyGridLayout copies the layout data for one grid to another.
GetsGridLayout - GetsGridLayout is the actual work procedure for applying a grid layout to a grid.
PutsGridLayout - PutsGridLayout is the actual work procedure for retrieving a grid layout from a grid into three string variables.
ReadGridLayout - ReadGridLayout is an interface procedure to set a certain set of values for column order, width and visibility.
WriteGridLayout - WriteGridLayout is an interface procedure to save a certain set of values for column order, width and visibility.

Types

TGridLayoutOption
TGridLayoutOptions
TIniFileType

Constants

glAll
TitleCaption

Variables

DlgColumnVisible


Functions


procedure CopyGridLayout( var i,o: TDataSource; opt: TGridLayoutOptions);

CopyGridLayout copies the layout data for one grid to another. It is necessary that both grids hold exactly the same number of fields and name them in the same way. Again, is only applied to the layout data (order, visibility or width) that are indicated by the options argument.

procedure GetsGridLayout( var ds: TDataSource; opt: TGridLayoutOptions; var v, o, w: string);

GetsGridLayout is the actual work procedure for applying a grid layout to a grid. It receives three strings that hold comma-separated integer values that denote visibility, order and display width informationfor each column in the grid associated with the datasource. The string values are broken down into individual values using StrParse and then applied to the individual columns of the grid. The position in which a particular value appears in one of the three input strings is the same as the index of the associated field in the alphabetically sorted fieldnames array of the grid. The visibility, width and order are only set when the corresponding option value is set in the options array.

procedure PutsGridLayout( var ds: TDataSource; opt: TGridLayoutOptions; var v, o, w: string);

PutsGridLayout is the actual work procedure for retrieving a grid layout from a grid into three string variables. It produces three strings that on ooutput hold comma-separated integer values that denote visibility, order and display width informationfor each column in the grid associated with the datasource. The string values are merged into strings from then individual column values using StrMerge. The position in which a particular value appears in one of the three output strings is the same as the index of the associated field in the alphabetically sorted fieldnames array of the grid. The visibility, width and order are only gotten when the corresponding option value is set in the options array.

procedure ReadGridLayout( var ds: TDataSource; opt: TGridLayoutOptions; var ini: TIniFileType; section, id: string);

ReadGridLayout is an interface procedure to set a certain set of values for column order, width and visibility. The set of values is read from the given INI file, using the given section header and value string prefixes. The read values are applied to the dataset associated with the given datasource. When you want to do this for a subset of the visibility, display width and display order of a grid, use another set of option constants instead of glAll.

procedure WriteGridLayout( var ds: TDataSource; opt: TGridLayoutOptions; var ini: TIniFileType; section, id: string);

WriteGridLayout is an interface procedure to save a certain set of values for column order, width and visibility. The set of values is read from the given ds.DataSet and written to the given INI file, using the given section header and value string prefixes. When you want to do this for a subset of the visibility, display width and display order of a grid, use another set of option constants instead of glAll.

Types


TGridLayoutOption  = ( glWidths, glOrder, glVisible);

TGridLayoutOptions = set of TGridLayoutOption

TIniFileType  = TIniFile
These conditionals are here because in my own production code I use the EasyINI component instead of the standard Delphi IniFile. Also, the title caption of the dialog is in Dutch.

Constants

glAll = [ glWidths, glOrder, glVisible]

TitleCaption = 'Visible grid columns'


Variables

DlgColumnVisible : TDlgColumnVisible