BpcSMScriptLibrary 15

From RiskWiki

Jump to: navigation, search

TDBAdvGrid Routines

Language: Delphi 7 - 2007

These routines provide additional manipulation and support for the TMS TDBAdvGrid and TAdvGrid components from TMS Software. They require these components to function. The TMS components are available from TMS Software http://tmssoftware.com/

//////// TDBAdvGrid  Routines


uses Classes, Types, DB, Grids, BaseGrid, AdvGrid, DBAdvGrid, AdvObj;

  TbpcTMSHiddenRowList = class (TIntList )
      function MapRowToRealRow( VisRow: Integer; VisRowCount: integer): integer;

// Returns the index of a TDBAdvGrid column given the name. -1 on failure
function bpcGetDBAdvGridColumnIndex( ColCollection: TDBGridColumnCollection; ColName : string) : Integer;
// Returns the TDBAdvGrid column given the name. nil on failure
function bpcGetDBAdvGridColumn( ColCollection: TDBGridColumnCollection; ColName : string) : TDBGridColumnItem;
// Returns the index of a TDBAdvGrid column given the field name. -1 on failure
function bpcGetDBAdvGridColumnByFieldIndex( ColCollection: TDBGridColumnCollection; FieldName : string) : Integer;
// Returns the TDBAdvGrid column given the Field name. nil on failure
function bpcGetDBAdvGridColumnByField( ColCollection: TDBGridColumnCollection; FieldName : string) : TDBGridColumnItem;

// Group and Filter Safe DBAdvGrid Page Mode Reload (Reloads Non page mode grid from dataset, after optional dataset refresh
// Reestablishes groups and filters and position.
function bpcDBAdvGridSafeReload( DBAdvGrid1: TDBAdvGrid; WithDataSetRefresh : boolean=False ) : TDBAdvGrid;
// Similar to TDBAdvGrid.Narrow, except that this one adds (logical and) filters rather than replacing filters, so with
// each call the additional filter applies to the last filtered result.  To clear the filters simply assign a condition of ''.
// FLastFilter is used to store the last filter string for the current filter.  If the new codition varies by only a character from the previous filter,
// it updates the previous filter rather than adding an additional filter. Clearing FLastFilter with each call prevents this behaviour.
function bpcDBAdvGridNarrowDown( MyGrid : TDBAdvGrid; Var FLastFilter : string; ACondition: string; AColumn: integer = -1) : TDBAdvGrid;
// Safe vis row to real row index conversion (This handles incrementally applied filters where the hidden row list is an accumulated list of multiple
// succeeding ordered hidden row lists.  It essentially deconstructs that portion of the rows it needs by reversing algorythmically the
// row visibility changes applied to date.  The second routine allows a marginal performance saving where mutliple access are
// required to the same grid filter state. Note bpcDBAdvGridSafeReload without dataset refresh rebuilds the hidden list from scratch and makes
// the TMS real coord routines safe to use again - as an alternative to this routine.
function bpcDBAdvGridVisRowToRealRow( DBAdvGrid1: TDBAdvGrid;  VisRow : integer ) : integer; overload;
function bpcDBAdvGridVisRowToRealRow( DBAdvGrid1: TDBAdvGrid;  VisRow : integer; var ListHidden: TbpcTMSHiddenRowList ) : integer; overload;
// Return the values for a column as a comma separated list of rows
function bpcDBAdvGridVisColToRowList( DBAdvGrid1: TDBAdvGrid; const FieldName : string; Sep : string=''; const QuoteMe : string='' ) : string;
function bpcDBAdvGridVisColToQuotedRowList( DBAdvGrid1: TDBAdvGrid; const FieldName : string; Sep : string='' ) : string;
// True if the grid is currently empty of datarows - equivalent to tdatasource is empty.
function bpcDBAdvGridIsEmpty( DBAdvGrid1: TDBAdvGrid ) : boolean;

function bpcDBAdvGridGetFieldList( DBAdvGrid1: TDBAdvGrid; bKeepEmptyFields : boolean=False; StartAtCol : integer=1 ) : TStringDynArray ;


CopyRight Bishop Phillips Consulting Pty Ltd 1997-2012 ( BpcSMScriptLibrary 15 )
Personal tools