Recent

Author Topic: [SOLVED] Controlling the behavior - JVCLLaz - JvDBLookUpCombo?  (Read 8522 times)

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 460
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
I've been using JvDBLookUpCombo from the JVCLLaz components for a few months. Haven't taken the time to post but I can figure out how to make the drop-down display more than one field properly.  Turning on AutoSize, RightTrimmedLookup, FieldDelimiter attempting to get the drop-down to display Contact Lastname, Firstname, Mi.  I can make it work if I change ListStyle to IsDelimited but IsFixed just displays the first field.  This works fine for States and Countries looking up a state abbrev. and the fullname of the state using IsFixed with the delimiter char#124 which is a vertical line char. Looks good. Also, if I use JvDBLookUpCombo for Firm Types, i.e. the Firm Type, Description.  The Description doesn't even show if I use IsFixed, I think it's a field length issue...
« Last Edit: May 03, 2024, 05:29:28 pm by 1HuntnMan »

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 460
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #1 on: March 24, 2024, 04:35:06 pm »
Basically what I'm inquiring here is to display the drop-down nice and neat in columns delimited with IsFixed and not IsDelimited. If the user wants to lookup a contact in the Clients form, the JVDbLoopDropDown just desplays the contact last name if I set the ListStyle to IsFixed.  If I set it to IsDelimited, works but the delimiter between LName, FName & Mi are delimited with commas, not ASCII char. #124. Now, for states or countries, the dropdown is delimited IsFixed with #124 which shows the state abbrev. | state name. Maybe it's a width issue????

jamie

  • Hero Member
  • *****
  • Posts: 7891
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #2 on: March 24, 2024, 08:09:21 pm »
I don't have those controls installed; however, does it have an optional OwnerDraw event?

if so, you can paint the data to the cells as you wish.
The only true wisdom is knowing you know nothing

rvk

  • Hero Member
  • *****
  • Posts: 7064
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #3 on: March 25, 2024, 08:00:45 am »
Maybe it's a width issue????
What is the field width of the used SQL?

Maybe try with a SQL where you cut off the longer strings (with SUBSTRING or something)?

State is probably a CHAR(2) so is always limited in size.
But if your COMPANYNAME is VARCHAR(100) or higher, it could be that the maximum possible string is taken, resulting in the other columns being pushed out of view.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 460
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #4 on: March 26, 2024, 07:04:00 pm »
Jamie,
   See below screenshots of the Properties for the JvDBLookUpCombo. I've experimented with basically AutoSize & the RightTrimmedLookUp turning one off and the other on, vise versa or with both on.  These screen shots are for State/Provinces lookup, i.e. State Code and State Full Name. This works perfectly.  Now the State Code is primary/unique.  I can't tell from the properties have anything to do with an index.  See what you think:


1HuntnMan

  • Sr. Member
  • ****
  • Posts: 460
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #5 on: March 26, 2024, 07:04:53 pm »
Jamie, scrnshot # 2:

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 460
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #6 on: March 26, 2024, 07:05:45 pm »
Jamie, scrnshot # 3, that's it for the properties...

rvk

  • Hero Member
  • *****
  • Posts: 7064
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #7 on: March 26, 2024, 07:31:45 pm »
This works perfectly.  Now the State Code is primary/unique.  I can't tell from the properties have anything to do with an index.  See what you think:
So... You show the settings for the instance where it works perfect.
So what is the problem?

Why not show the settings for your problem case.
And also post the images of the actual problem running your program.

And like I already asked... what is the sql and types of the fields?
If you have a varchar(50) as first column then it will take that much space to accommodate those characters, pushing away the second column.


rvk

  • Hero Member
  • *****
  • Posts: 7064
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #8 on: March 26, 2024, 07:50:58 pm »
Also note this...

Quote
ListStyle determines how the lookup list displays its items when multiple fields specified by the LookupDisplay property. By default, style is lsFixed, meaning that the each display field always takes up a fixed width accordingly to their DisplayWidth properties. The lsDelimited style meaning that each field takes a variable width, and the fields are separated by the FieldsDelimiter character.
https://wiki.delphi-jedi.org/wiki/JVCL_Help:TJvDBLookupCombo.ListStyle

So like I said... Look at the displaywidth of your fields.
You might want to cut them short in your sql statement for the first field/column.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 460
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #9 on: March 26, 2024, 09:44:24 pm »
Rvk, not SQL.  TDbf...

The settings for the one that works, which you see in the captured images is the same as the ones that don't work.  I think the issue is the length of the selected field and the additional field. In the example images, the State Code is 2 char. and the state name is 25. But, if I have a lookup table for customer types which is TypeFirm=20 and Description=40. DropDown displays only the TypeFirm set exactly the same as the StateProv lookup table.  Also, looking up the main contact for a client.  Contact Lastname=15, Firstname=15.  This doesn't display correctly either.  No logic here to me. Now if you look at the property, ListStyle. If you set it to IsFixed, the dropdown fields are listed separated by ASCII #124=| Which looks nice and neat. The only way to get contacts to display both fields in the drop-down is to change the ListStyle to IsDelimited.  But, it doesn't matter what ASCII char. in the FieldsDelimiter property, IsDelimited displays both LastName, Firstname separated by , comma.  So, I'm forgetting about trying to have this DropDown component display 2-3 fields aligned correctly on some of these dropdowns.  I think it must be a field length issue with the first field which is being set and stored into the main table field, in this case the Clients table-Contact LastName.
This probably isn't too clear but moving on... spent too much time on this.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 460
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #10 on: March 26, 2024, 09:46:03 pm »
I might research to find out who wrote/designed JvDBLookUpCombo and communicate with the designer.

rvk

  • Hero Member
  • *****
  • Posts: 7064
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #11 on: March 26, 2024, 09:55:35 pm »
But, if I have a lookup table for customer types which is TypeFirm=20 and Description=40. DropDown displays only the TypeFirm set exactly the same as the StateProv lookup table.  Also, looking up the main contact for a client.  Contact Lastname=15, Firstname=15.  This doesn't display correctly either.  No logic here to me.
The dislaywidth for TypeForm and Lastname are too large and push the other fields to the right.
You should see this if you set the width of your component to a very large width.

If you see the Description and Firstname then, you need to make the displaywidth of the first fields smaller. It's as simple as that.

Now if you look at the property, ListStyle. If you set it to IsFixed, the dropdown fields are listed separated by ASCII #124=| Which looks nice and neat. The only way to get contacts to display both fields in the drop-down is to change the ListStyle to IsDelimited.
No it's not. You need to make the displaywidth of the first field smaller so it doesnt push the second out of view.

I think it must be a field length issue with the first field which is being set and stored into the main table field, in this case the Clients table-Contact LastName.
That's what I keep saying. Set the displaywidth of the first field to a smaller number and they will display.
https://www.freepascal.org/docs-html/fcl/db/tfield.displaywidth.html

You don't need to change the field itself. Just the displaywidth.

This probably isn't too clear but moving on... spent too much time on this.
That's a choice too ;)

wp

  • Hero Member
  • *****
  • Posts: 13649
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #12 on: March 26, 2024, 10:18:01 pm »
Did you look at the sample project in folder examples/JvDBLookup of the JVCL installation?

Code: Pascal  [Select][+][-]
  1.   Cities.FieldByName('NAME').DisplayWidth := 10;
  2.   Cities.FieldByName('COUNTRY').DisplayWidth := 10;      

Here the combobox displays the fields "NAME" and "COUNTRY" of the dataset "Cities". Both are string fields created with a field width of value 16. Reducing the field's DisplayWidth to 10 instructs the combobox to reserve less space for the record values.

The width numbers are the count of characters. Note that in case of proportional fonts the columns are calculated on the assumption that each character requires the width of an "M". This way good column alignment can be achieved at the expense of inaccurate column widths.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 460
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #13 on: March 27, 2024, 06:58:53 pm »
Okay All, thanks for the help.
WP's advice to look at the example of JvDBLookUp did it. I'm going to incorporate the settings from the example into my app and think I can get the behavior that's a bit more user friendly for what I'm wanting. Take care and thanks all who commented!

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 460
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #14 on: March 27, 2024, 07:08:44 pm »
Also, what is TBufDataSet? Also, TMemDataSet? TBufDataSet appears to be a temporary data holder correct?

Also, what would you experts recommend for a manual to learn some or more than what I've learned from the Laz/FPC tutorials, experimentation, try it and see what happens, etc.?  Is the Lazarus Handbook a good buy?

 

TinyPortal © 2005-2018