View Issue Details

IDProjectCategoryView StatusLast Update
0001678JEDI VCL00 JVCL Componentspublic2004-04-22 23:39
ReporterhamiltonAssigned Touser72 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001678: JvDBLookupCombo does not perform case insensitive search
DescriptionI am placing a JvDBLookupCombo on a form and assigning just the datasource and datafield properties to display a fkLookup field of a ClientDataSet.

Changing the value of the IgnoreCase property has no effect.
Additional InformationThis behaviour is replicable using code from 2004-04-21
TagsNo tags attached.

Activities

user72

2004-04-22 00:04

  ~0003984

The problem seems to be associated with TJvLocateObject.Locate, s0 could you set a breakpoint at the first line and step through the code to see where it goes south?

hamilton

2004-04-22 07:35

reporter   ~0004008

Your lead turned out to be correct, the problem was in the Locate method.

The dataset field I was testing with is of type ftWideString rather than ftString that Locate expected.

The line that needs to be changed in TJvLocateObject.Locate is:
  if FLookupField.DataType <> ftString then
It needs to be replaced with:
  if not ((FLookupField.DataType = ftString) or (FLookupField.DataType = ftWideString)) then

user72

2004-04-22 23:39

  ~0004020

I made a slightly different change to make it easier to add new types if necessary:

function TJvLocateObject.Locate(const KeyField, KeyValue: string;
  Exact, CaseSensitive: Boolean): Boolean;
var
  LookupKey: TField;
  function IsStringType(FieldType:TFieldType):boolean;
  const
    cStringTypes = [ftString, ftWideString];
  begin
    Result := FieldType in cStringTypes;
  end;

begin
  if DataSet = nil then
  begin
    Result := False;
    Exit;
  end;
  DataSet.CheckBrowseMode;
  LookupKey := DataSet.FieldByName(KeyField);
  DataSet.CursorPosChanged;
  FLookupField := LookupKey;
  FLookupValue := KeyValue;
  FLookupExact := Exact;
  FCaseSensitive := CaseSensitive;
  if not IsStringType(FLookupField.DataType) then
  begin
    FCaseSensitive := True;
    try
      CheckFieldType(FLookupField);
    except
      Result := False;
      Exit;
    end;
  end
  else
    FCaseSensitive := CaseSensitive;
  FBookmark := DataSet.GetBookmark;
  try
    DataSet.DisableControls;
    try
      Result := MatchesLookup(FLookupField);
      if not Result then
      begin
        if UseKey then
          Result := LocateKey
        else
        begin
          if FilterApplicable then
            Result := LocateFilter
          else
            Result := LocateFull;
        end;
        if not Result then
          SetToBookmark(DataSet, FBookmark);
      end;
    finally
      DataSet.EnableControls;
    end;
  finally
    FLookupValue := EmptyStr;
    FLookupField := nil;
    DataSet.FreeBookmark(FBookmark);
    FBookmark := nil;
  end;
end;

Updated in CVS

Issue History

Date Modified Username Field Change
2004-04-21 04:00 hamilton New Issue
2004-04-22 00:04 user72 Note Added: 0003984
2004-04-22 00:04 user72 Status new => feedback
2004-04-22 07:35 hamilton Note Added: 0004008
2004-04-22 23:39 user72 Status feedback => resolved
2004-04-22 23:39 user72 Resolution open => fixed
2004-04-22 23:39 user72 Assigned To => user72
2004-04-22 23:39 user72 Note Added: 0004020