Jump to content

TUniDBComboBox with ITEMS+VALUES


Recommended Posts

Hello everyone
 
finally I'm using this library to a project.
 
I ask you to have a component as TUniDBComboBox /TUniComboBox
that besides having the property Items
has properties by Values
to display a label
and set in the database a different value,
Thank you

 

<ul class="x-list-plain">

 <li value="C">Coffee</li>

  <li value="T">Tea</li>

  <li value="M">Milk</li>

  <li value="W">Water</li>

  <li value="J">Juice</li>

  <li value="B">Beer</li>

<ul>

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 year later...
  • 2 months later...

I discovered a small flaw in the component from @gerardocrisci...   if you change the item in the list but cancel the edit (call TDataset.Cancel), the component does not refresh and revert back to the previous value as stored in the table.  It will continue to show the new selected item from the list.
 
You can fix this by inserting:
 
  if DataLink.Editing = false then begin
    InternalText := value+'1';  // gives reason to send change back to browser.
  end;
 
before 
 
  Text := Value;
 
in the DataChange Method.    
 
I tried to attached a fixed version but the form won't let me...  - Thank you so much @gerardocrisci for your original component and work.  :)

 

 

Link to comment
Share on other sites

Thank you gerardocrisci - I just tried your updated component, but it still has the flaw I described in my post.  If you use your combobox to change the dataset value, but then cancel the change (dataset.cancel) instead of post, the component should switch back to showing the original value that it started with to match the dataset.  Yours does not do this.  It will continue to show the newly selected value even though it does not now match what is in the dataset. If you make the change I suggested, or some variation of it, it will reset to the correct value as it should. 

 

There is a similar flaw that occurs when the component is connected to an empty dataset, a record is inserted or appended, and then then canceled.  Like with the changed record, it keeps the new value instead of going blank like it should for an empty dataset.  

 

To fix that, add the following code AFTER the 

 

  Text := Value;
 
in the DataChange Method.    
 
  if datalink.Field <> nil then begin
    if datalink.Field.IsNull then begin
      InternalText := '1';
      text := '';
    end;
  end;
 

 

 

With those changes, I have made very good use of your component in several projects and I thank you again for your original work.

 

Cheers! :)

  • Upvote 2
Link to comment
Share on other sites

  • 5 months later...

Hi  gerardocrisci

I am trying to use this component as an inplace editor in dbgrid. Do you know how can I force the grid to display Items instead of values? What I mean is, let's say the value in the dataset is 'CHAR' but I want to display 'Alphanumeric' for every row that has this value. Can you help me?

 

 

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...
  • 2 years later...
On 7/21/2018 at 8:08 AM, Sherzod said:

Hello,

 

Which edition and build are you using?

The component works fine, but why the procedure DoSetRemoteValue(AIndex:Integer; Value: string) is not called when the component is included in a hidden panel (within a dbgrid)? this causes it to fail...

Link to comment
Share on other sites

  • 4 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...