Jump to content


Photo

DisplayText data aware items


  • Please log in to reply
8 replies to this topic

#1 Gerry

Gerry
  • Members
  • 26 posts
  • Gender:Male
  • Location:North of Chicago
  • Interests:None

Posted 08 July 2009 - 11:05 PM

Dear Bojan,

TField objects have a property OnGetText where you can change the edit / display string of the field value. Unfortunately this is not (yet) supported in NxDbInspector. I had to overwrite the GetDisplayText method to get this feature supported (see below). This patch works for me but it's only part of the solution. There are more data aware item classes. I hope you can update your code soon.

Thanks,

Gerry

=== My Patch ===

function TNxDBTextItem.GetDisplayText: WideString;
begin

with GetParentControl as TNextDBInspector do begin
if (DataSource <> Nil) and (DataSource.DataSet <> Nil) and (DataSource.DataSet.Active) then
Result := DataSource.DataSet.FieldByName(FieldName).DisplayText else
Result := Value;
end;

end; { .GetDisplayText }

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 08 July 2009 - 11:56 PM

Hello Gerry,

Thank you for your code. I will look further on this issue, to complete it with help of your code.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 10 July 2009 - 03:32 PM

Hello Gerry,

I maybe have one solution.

1. Open NxDBInspector.pas file.
2. Find body of:

CODE
procedure TItemDataLink.UpdateItems;


3. Replace its code by next code:

CODE
procedure TItemDataLink.UpdateItems;
var
  i: Integer;
  DataField: TField;
begin
  with FOwner do Include(FPropertiesState, psUpdating);
  for i := 0 to FOwner.Items.Count - 1 do
    with Fowner.Items[i] do
    begin
      DataField := DataSet.Fields.FindField(FieldName);
      if Assigned(DataField) then
      begin
        if not DataField.IsNull then
        begin
          case DataField.DataType of
            ftString, ftMemo: AsString := DataField.DisplayText; // <------ Modified line
            ftWideString: AsString := TWideStringField(DataField).Value; // <----- New line
            ftInteger, ftWord, ftSmallint, ftAutoInc, ftLargeint: AsInteger := DataField.AsInteger;
            ftFloat, ftCurrency, ftBCD, ftFMTBcd: AsFloat := DataField.AsFloat;
            ftBoolean: AsBoolean := DataField.AsBoolean;
            ftDate, ftDatetime, ftTime, ftTimeStamp: AsDatetime := DataField.AsDateTime;
            else AsString := DataField.AsString;
          end;
        end else AsString := '';
      end;
    end;
  with FOwner do Exclude(FPropertiesState, psUpdating);
end;


I hope that this helps now.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#4 Gerry

Gerry
  • Members
  • 26 posts
  • Gender:Male
  • Location:North of Chicago
  • Interests:None

Posted 10 July 2009 - 04:41 PM

If you look at the OnGetText event of TField you can see it has a second parameter DisplayText. Depending on it's value the function must return a string for editing or displaying. Looking at your updated code you would always return the display text.

Example:

Suppose I have an inspector item where I can enter a part number like P007, when moving to another item (or another control) the item text should change to 'Next DBGrid and Next Grid - Full source and all future updates'.

So, when an item receives focus it should use the 'value' text (DisplayText=False) and when loosing focus it should use the display text (DisplayText=True). When it has focus the user can edit the 'P007' string. Hope this helps.

Kind regards,

Gerry

#5 Gerry

Gerry
  • Members
  • 26 posts
  • Gender:Male
  • Location:North of Chicago
  • Interests:None

Posted 12 August 2009 - 01:03 PM

I'm a little disappointed I have to apply my patch to the latest version (08-05-09) of your components to get this issue fixed. Get the feeling you completely ignored my previous post.

#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 12 August 2009 - 02:14 PM

Hello Gerry,

Please sorry for delay, I was fully bussy. I didn't have enough time to include this change into latest release. I am just one man smile.gif

Please sorry for delay again. I will do my best to something include in next release or quick fix.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#7 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 12 August 2009 - 11:29 PM

Hello Gerry,

Please sorry for delay again, I have remember why I didn't go further with this fix.

Problem is that every DB Item need to have this code which can make a problem with consistency.

Do you have some other idea how this may be implemented, even in root NxPropertyItem class. I am not sure how duplicating code for each class can be avoided. Maybe something may be done with Interfaces, but I can have idea.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#8 Gerry

Gerry
  • Members
  • 26 posts
  • Gender:Male
  • Location:North of Chicago
  • Interests:None

Posted 13 August 2009 - 08:21 PM

Dear Bojan,

I was way to harsh in my previous forum post. I know you are working alone and trying to do your best. Sorry for that. I will stop using the forum for reporting bugs. It’s better to do it by email.

Kind regards,

Gerry

#9 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 13 August 2009 - 10:12 PM

Hello Gerry,

You may still report problems on forum, without any trouble smile.gif This is why forum is supposed to be used smile.gif

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users