View Issue Details

IDProjectCategoryView StatusLast Update
0002784JEDI VCL00 JVCL Componentspublic2005-04-01 06:04
Reportercab-dkAssigned Toobones 
Status resolvedResolutionwon't fix 
Product Version3.00 BETA 2 
Target VersionFixed in Version 
Summary0002784: Issue 2783
DescriptionI'm the reporter and I have a solution on the doTitleClick
Additional Informationprocedure TJvDBGrid.DoTitleClick(ACol: Longint; AField: TField);
  cIndexName = 'IndexName';
  cIndexDefs = 'IndexDefs';
  cMasterFields = 'MasterFields';
  cDirection: array [Boolean] of TSortMarker = (smDown, smUp);
  IndexDefs: TIndexDefs;
  LIndexName: string;
  Descending: Boolean;
  IndexFound: Boolean;

  function GetIndexOf(AFieldName: string; var AIndexName: string; var Descending: Boolean): Boolean;
    I, FieldNo: Integer;
    IsDescending: Boolean;
    MasterFields: string;

    Result := False;
    FieldNo := 99;
    if IsPublishedProp(DataSource.DataSet, cMasterFields) then
      MasterFields := GetStrProp(DataSource.DataSet, cMasterFields);
    if MasterFields <> '' then
      MasterFields := MasterFields + ';';

    for I := 0 to IndexDefs.Count - 1 do
      if (Pos(MasterFields + AFieldName, IndexDefs[I].Fields) > 0) and
         (Pos(MasterFields + AFieldName, IndexDefs[I].Fields) <= FieldNo) then
        FieldNo := Pos(MasterFields + AFieldName, IndexDefs[I].Fields);
        AIndexName := IndexDefs[I].Name; // best match so far
        IsDescending := (ixDescending in IndexDefs[I].Options);
        Result := True;
        if Descending <> IsDescending then
          // we've found an index that is the opposite direction of the previous one, so we return now
          Descending := IsDescending;
      // if we get here and Result is True, it means we've found a matching index but it
      // might be the same as the previous one...

  IndexFound := False;

  if AutoSort and IsPublishedProp(DataSource.DataSet, cIndexDefs) and
    IsPublishedProp(DataSource.DataSet, cIndexName) then
    IndexDefs := TIndexDefs(GetOrdProp(DataSource.DataSet, cIndexDefs))
    IndexDefs := nil;
  if Assigned(IndexDefs) then
    Descending := SortMarker = smUp;
    if GetIndexOf(AField.FieldName, LIndexName, Descending) then
      IndexFound := True;
      SortedField := AField.FieldName;
      SortMarker := cDirection[Descending];
        SetStrProp(DataSource.DataSet, cIndexName, LIndexName);
  // FBC: 2004-02-18
  // Following code handles the sortmarker if no Index is found.
  // the actual data-sorting must be implemented by the user in
  // event OnTitleBtnClick.
  if AutoSort and not IndexFound then
    if SortedField = AField.FieldName then
      case Self.SortMarker of
          Self.SortMarker := smDown;
          Self.SortMarker := smUp;
      SortedField := AField.FieldName;
      Self.SortMarker := smUp;
  if Assigned(FOnTitleBtnClick) then
    FOnTitleBtnClick(Self, ACol, AField);

TagsNo tags attached.


related to 0002783 resolvedobones TitleClick to select index results in wrong index. 



2005-04-01 06:04

administrator   ~0006817

From Fred and Dom:
the sorting function in JvDBGrid is very crappy. I didn't remove it because I thought some people could find a use for it, BUT PLEASE DON'T USE IT (and if you do, don't complain). Use JvDBUltimGrid and its sorting function instead.

Issue History

Date Modified Username Field Change
2005-03-20 04:36 cab-dk New Issue
2005-03-20 22:47 jfudickar Relationship added related to 0002783
2005-04-01 06:04 obones Status new => resolved
2005-04-01 06:04 obones Resolution open => won't fix
2005-04-01 06:04 obones Assigned To => obones
2005-04-01 06:04 obones Note Added: 0006817