View Issue Details

IDProjectCategoryView StatusLast Update
0006115JEDI VCL00 JVCL Componentspublic2014-01-29 09:58
ReporterSFAssigned To 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version3.47 
Target VersionFixed in Version 
Summary0006115: AutoSort in JvDBUltimGrid
DescriptionAutosort of ClientDataSet, by clicking title (button), always creates a new index (_Idx_1, _Idx_2 etc)instead of re-using the same again (procedure = SetClientIndex).

As far as I can see, this could solve this issue:

  procedure SetClientIndex(SortField: TField);
  const
    cIndexPrefix = '_Idx_';
  var
    IndexDefs: TIndexDefs;
    I: Integer;
    NewIndexName: string;
  begin
    IndexDefs := TIndexDefs(GetOrdProp(DSet, cIndexDefs));
    // Start change 1 (remark of the next line)
// IndexDefs.Update; It seems like "Update" clears the "IndexDefs.Items[I].DescFields" out = always empty.
    // End change 1
    { Search for an existing index... }
    for I := 0 to IndexDefs.Count - 1 do begin
      if (Pos(cIndexPrefix, IndexDefs.Items[I].Name) = 1) and // Search among the indexes this procedure creates by itselt.
         (AnsiSameText(SortString, IndexDefs.Items[I].Fields)) and
         (AnsiSameText(DescString, IndexDefs.Items[I].DescFields))
      then begin
        NewIndexName := IndexDefs.Items[I].Name;
        UpdateProp(cIndexName, NewIndexName, SortField);
        Break;
      end
    end;
    { ... or else create a new one }
    // Start change 2
    if I = IndexDefs.Count then
    begin
    // End change 2
      Inc(FIndexCounter);
      NewIndexName := cIndexPrefix + IntToStr(FIndexCounter{IndexDefs.Count});
      with IndexDefs.AddIndexDef do begin
        Name := NewIndexName;
        Fields := SortString;
        CaseInsFields := SortString;
        DescFields := DescString;
      end;
      UpdateProp(cIndexName, NewIndexName, SortField);
    // Start change 3
    end;
    // End change 3
  end;
TagsNo tags attached.

Activities

obones

2013-12-13 10:49

administrator   ~0020718

Please try with the latest JVCL version in GIT (or daily zip) and then send us a zipped file containing the sources of an application showing the issue.

2014-01-16 16:58

 

0006115.zip (82,776 bytes)

SF

2014-01-16 16:59

reporter   ~0020897

Attach is an application displaying this issue!

Issue History

Date Modified Username Field Change
2013-04-03 10:49 SF New Issue
2013-12-13 10:49 obones Note Added: 0020718
2013-12-13 10:49 obones Status new => feedback
2014-01-16 16:58 SF File Added: 0006115.zip
2014-01-16 16:59 SF Note Added: 0020897
2014-01-29 09:58 obones Status feedback => acknowledged