Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: IWDBComboBox do not show the NoSelectionText?



Permlink Replies: 21 - Last Post: Oct 31, 2017 10:10 PM Last Post By: Dan Barclay Threads: [ Previous | Next ]
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2017 10:26 AM
In the IWComboBox i set ItemIndex to 0,1, etc and then do not show NoSelectionText, great, BUT in the IWDBComboBox i set ItemIndex to 0,1, etc and then show NoSelectionText.
What do I do not to show or is a bug?
<select class="form-control" id="IWCOMBOBOX_BUSCA" name="IWCOMBOBOX_BUSCA" size="1" style="" tabindex="3">
<option selected="" value="0">NOME</option>
<option value="1">FANTASIA</option>
<option value="2">CIDADE</option>
<option value="3">CONTATO</option>
<option value="4">EMAIL</option></select>

<select class="form-control" id="IWDBCOMBOBOX_FIS_JUR" name="IWDBCOMBOBOX_FIS_JUR" size="1" style="" tabindex="35" title="">
<option selected="" value="-1">-- No Selection --</option>   <=========here
<option value="F">Física</option>
<option value="J">Jurídica</option></select>
Chad Hower

Posts: 613
Registered: 3/2/07
Re: IWDBComboBox do not show the NoSelectionText? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2017 3:22 PM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
DBComboBoxes take their selection from the data bound value.

On 10/7/2017 1:30 PM, Jose Nilton Pace wrote:
In the IWComboBox i set ItemIndex to 0,1, etc and then do not show NoSelectionText, great, BUT in the IWDBComboBox i set ItemIndex to 0,1, etc and then show NoSelectionText.
What do I do not to show or is a bug?
<select class="form-control" id="IWCOMBOBOX_BUSCA" name="IWCOMBOBOX_BUSCA" size="1" style="" tabindex="3">
<option selected="" value="0">NOME</option>
<option value="1">FANTASIA</option>
<option value="2">CIDADE</option>
<option value="3">CONTATO</option>
<option value="4">EMAIL</option></select>

<select class="form-control" id="IWDBCOMBOBOX_FIS_JUR" name="IWDBCOMBOBOX_FIS_JUR" size="1" style="" tabindex="35" title="">
<option selected="" value="-1">-- No Selection --</option>   <=========here
<option value="F">Física</option>
<option value="J">Jurídica</option></select>

Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: IWDBComboBox do not show the NoSelectionText? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 8, 2017 5:25 AM   in response to: Chad Hower in response to: Chad Hower
Chad, the behavior is different ComboBox <-> DBComboBox, Think with me.

ComboBox with ItemIndex := -1, show "-- No Selection --", it´s OK.
ComboBox with ItemIndex := 0, don´t show "-- No Selection --", it´s OK.

*DB*ComboBox with ItemIndex := -1, show "-- No Selection --", it´s OK.
*DB*ComboBox with ItemIndex := 0, show "-- No Selection --", it´s the problem.

I think the *DB*ComboBox with ItemIndex := 0, should NOT show "-- No Selection --".
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: IWDBComboBox do not show the NoSelectionText? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 8, 2017 7:41 AM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
Jose Nilton Pace wrote:
Chad, the behavior is different ComboBox <-> DBComboBox, Think with me.

ComboBox with ItemIndex := -1, show "-- No Selection --", it´s OK.
ComboBox with ItemIndex := 0, don´t show "-- No Selection --", it´s OK.

*DB*ComboBox with ItemIndex := -1, show "-- No Selection --", it´s OK.
*DB*ComboBox with ItemIndex := 0, show "-- No Selection --", it´s the problem.

I think the *DB*ComboBox with ItemIndex := 0, should NOT show "-- No Selection --".

I thought I understood what you were saying, now I'm not so sure what you mean by "show". By "show", do you mean the difference between visible and not visible, or do you mean the difference between selected and not selected?

With the DB, I think you'll control which is selected by setting the current row of the DB. It's been a year or two since I worked with the DB controls, but see if that is the issue if you are talking about selection (vs visibility).

Dan
Chad Hower

Posts: 613
Registered: 3/2/07
Re: IWDBComboBox do not show the NoSelectionText? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 8, 2017 1:39 PM   in response to: Dan Barclay in response to: Dan Barclay
On 10/8/2017 10:41 AM, Dan Barclay wrote:
With the DB, I think you'll control which is selected by setting the
current row of the DB. It's been a year or two since I worked with
the DB controls, but see if that is the issue if you are talking
about selection (vs visibility).

Exactly. DBCombos don't use the index that way. They get their values
from the bound field.
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: IWDBComboBox do not show the NoSelectionText? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 9, 2017 6:49 AM   in response to: Chad Hower in response to: Chad Hower
Chad Hower wrote:
Exactly. DBCombos don't use the index that way. They get their values
from the bound field.

Chad, i understand your point but where DBCombo get these values from:
<option selected="" value="-1">-- No Selection --</option>

These ARE my options in bound fields:
<option value="F">Física</option>
<option value="J">Jurídica</option>

tks.
Chad Hower

Posts: 613
Registered: 3/2/07
Re: IWDBComboBox do not show the NoSelectionText? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 9, 2017 8:57 AM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
On 10/9/2017 9:50 AM, Jose Nilton Pace wrote:
Chad Hower wrote:
Exactly. DBCombos don't use the index that way. They get their values
from the bound field.

Chad, i understand your point but where DBCombo get these values from:
<option selected="" value="-1">-- No Selection --</option>

These ARE my options in bound fields:
<option value="F">Física</option>
<option value="J">Jurídica</option>

It doesn't get just the fields to list from the DB, but which one to choose.

If the bound value does not match a choice in the list according to
binding, it will also show no value because it cant match one up.
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: IWDBComboBox do not show the NoSelectionText? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 9, 2017 9:20 AM   in response to: Chad Hower in response to: Chad Hower
Chad, I would like the DBComboBox to work the same as the ComboBox when I put ItemIndex := 0, it does not show the "-- No Selection --" option in <option>.
Just this. Is there any chance of that happening?
tks.
Chad Hower

Posts: 613
Registered: 3/2/07
Re: IWDBComboBox do not show the NoSelectionText? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 11, 2017 10:14 AM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
On 10/9/2017 12:20 PM, Jose Nilton Pace wrote:
Chad, I would like the DBComboBox to work the same as the ComboBox when I put ItemIndex := 0, it does not show the "-- No Selection --" option in <option>.
Just this. Is there any chance of that happening?

Why are you setting the ItemIndex instead of updating the bound field it
binds to?
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: IWDBComboBox do not show the NoSelectionText? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 11, 2017 10:35 AM   in response to: Chad Hower in response to: Chad Hower
Hi Chad, doesn't matter, the "-- No Selection --" option appears in <option></option> in both cases, itemindex or set field.

In this case the client select an option "-- No Selection --" with Value="-1" and BROKE my code, because i'm waiting "F" or "J" in field value not an integer -1.

In ComboBox, NOT DB, works as expected. The "-- No Selection --" option DOESN'T appear in <option></option> when a select ItemIndex <> -1.

tks.
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: IWDBComboBox do not show the NoSelectionText? [Edit] [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 11, 2017 3:20 PM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
Jose Nilton Pace wrote:
Hi Chad, doesn't matter, the "-- No Selection --" option appears in <option></option> in both cases, itemindex or set field.

In this case the client select an option "-- No Selection --" with Value="-1" and BROKE my code, because i'm waiting "F" or "J" in field value not an integer -1.

In ComboBox, NOT DB, works as expected. The "-- No Selection --" option DOESN'T appear in <option></option> when a select ItemIndex <> -1.

I don't use TIWDBCombobox often, but playing with a sample I do see the option for no selection in the DOM.
I added a IWDBCombobox to the DBGridControls demo, with a TIWButton that gets the .ItemIndex and shows it in a TIWText.

When the DOM element is converted to XML:
<select name="IWDBCOMBOBOX1" tabindex="1" class="IWDBCOMBOBOX1CSS" id="IWDBCOMBOBOX1" size="1">
<option value="-1">-- No Selection --</option>
<option value="0" selected="">Field 1 - Row 1</option>
<option value="1">Field 1 - Row 2</option></select>


Selecting the "No Selection" leaves the itemindex at -1

That said, the initial value is taken from a database row since a database row is selected (dataset cursor is active). I don't know if there is a way to disconnect the database cursor, or give it an "undefined" value but a data guy might be able to help on that.

In order to get the "No Selection" option removed, set "RequireSelection" property to TRUE. [edit: Mistyped earlier as False!]

Dan

Edited by: Dan Barclay on Oct 12, 2017 9:42 AM
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: IWDBComboBox do not show the NoSelectionText? [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 9, 2017 6:44 AM   in response to: Dan Barclay in response to: Dan Barclay
Hi Dan, show in <options></options>, you can see in the First post.
The client select an option "-- No Selection --" with Value="-1" and BROKE my code.
Because of this I think it should NOT appear in the <options></options>.
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 11, 2017 10:44 PM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
Hi Jose Nilton,

I'll check this issue and get back to you ASAP, OK?

Kind regards
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 11, 2017 11:42 PM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
Hi Jose Nilton,

IWDBComboBox renders correctly, just like IWComboBox.

Although ItemIndex is a public property of IWDBComboBox you shouldn't set it in order to change its value. You must set the underlying field. If the underlying field is set (and it matches one of the items on the list) and IWDBComboBox.RequireSelection is TRUE, IWDBComboBox will render just like IWComboBox and -- No Selection -- item won't be present in the list.

If you can't reproduce it and need a demo, please let me know and I can send you the test project.

Kind regards
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2017 5:36 AM   in response to: Alexandre Machado in response to: Alexandre Machado
Hi Alexandre, thank you for this step by step, but i can't reproduce. If you make a test project i appreciate. My code below:
  object IWDBComboBox_Fis_Jur: TIWDBComboBox
    Left = 17
    Top = 231
    Width = 121
    Height = 21
    Css = 'form-control'
    RenderSize = False
    StyleRenderOptions.RenderSize = False
    StyleRenderOptions.RenderPosition = False
    StyleRenderOptions.RenderFont = False
    StyleRenderOptions.RenderZIndex = False
    StyleRenderOptions.RenderVisibility = False
    StyleRenderOptions.RenderStatus = False
    StyleRenderOptions.RenderAbsolute = False
    StyleRenderOptions.RenderPadding = False
    StyleRenderOptions.RenderBorder = False
    Font.Color = clNone
    Font.Size = 10
    Font.Style = []
    ItemsHaveValues = True
    TabOrder = 34
    AutoEditable = False
    DataField = 'FIS_JUR'
    DataSource = DS_PARCAD
    FriendlyName = 'IWDBComboBox_Fis_Jur'
    ItemIndex = -1
    Items.Strings = (
      'Fisica=F'
      'Juridica=J')
    NoSelectionText = '-- No Selection --'
  end

procedure TIWF_PAR001_Cadastro.IWButton_IncluirAsyncClick(Sender: TObject; EventParams: TStringList);
begin
   FDQ_PARCAD.Open;
   FDQ_PARCAD.Append;
   FDQ_PARCADFIS_JUR.Value := 'J';
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2017 11:57 PM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
If you are setting the value in an Async event, both won't refresh the list. IWDBComboBox and IWComboBox will set the selected item, but won't remove -- No Selection -- item from list.

Try to do the same inside IWForm.OnCreate (or use Button's OnClick) event and you will see the difference.
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 13, 2017 5:24 AM   in response to: Alexandre Machado in response to: Alexandre Machado
Alexandre Machado wrote:
If you are setting the value in an Async event, both won't refresh the list. IWDBComboBox and IWComboBox will set the selected item, but won't remove -- No Selection -- item from list.

Try to do the same inside IWForm.OnCreate (or use Button's OnClick) event and you will see the difference.

Hi Alexandre, i CAN confirm that it worked as expected (Button's OnClick). Is there any way I can force refresh in async mode to remove --No Selection -- from list?

tks.
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2017 12:22 AM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
Jose Nilton Pace wrote:
Alexandre Machado wrote:
If you are setting the value in an Async event, both won't refresh the list. IWDBComboBox and IWComboBox will set the selected item, but won't remove -- No Selection -- item from list.

Try to do the same inside IWForm.OnCreate (or use Button's OnClick) event and you will see the difference.

Hi Alexandre, i CAN confirm that it worked as expected (Button's OnClick). Is there any way I can force refresh in async mode to remove --No Selection -- from list?

tks.

Sorry about the delay, José Nilton.

There is a method RefreshItems in all IWComboBox descendants. You can call it in Async so it will refresh completely:


procedure TIWForm25.IWButton1AsyncClick(Sender: TObject;
  EventParams: TStringList);
begin
  IWComboBox1.ItemIndex := 0;
  IWComboBox1.RefreshItems;
end;
 


It should fix your issue. I'll see if this behavior can be made automatic, i.e. without the need to call RefreshItems explicitly in code.

Kind regards
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2017 6:00 AM   in response to: Alexandre Machado in response to: Alexandre Machado
Hi, Alexandre. In DBComboBox don't need the ItemIndex:=0, only the RefreshItems has already solved.

If you can get the automatic refresh or when setting the value of the field, it would be beautiful and wonderful.

Thank You.
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2017 9:38 AM   in response to: Alexandre Machado in response to: Alexandre Machado
Alexandre Machado wrote:

There is a method RefreshItems in all IWComboBox descendants. You can call it in Async so it will refresh completely:

I had forgot about that method. I use it in TIWDBGrid. If you make it automatic, let me know. I haven't thought through why/if it might have a downside being auto but I can't think of a downside offhand.

Dan
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 31, 2017 1:58 AM   in response to: Dan Barclay in response to: Dan Barclay
Dan Barclay wrote:
Alexandre Machado wrote:

There is a method RefreshItems in all IWComboBox descendants. You can call it in Async so it will refresh completely:

I had forgot about that method. I use it in TIWDBGrid. If you make it automatic, let me know. I haven't thought through why/if it might have a downside being auto but I can't think of a downside offhand.

Dan

Hi Dan,

it used to be "automatic", i.e. all combo box was refreshed every time you changed selected item. It means that, if you have a huge combo, say, 1000 items, your Ajax response would be huge and performance suffers. However, I think we can make it automatic in this specific case.

Cheers
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: IWDBComboBox do not show the NoSelectionText?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 31, 2017 10:10 PM   in response to: Alexandre Machado in response to: Alexandre Machado
Alexandre Machado wrote:
Dan Barclay wrote:
Alexandre Machado wrote:

There is a method RefreshItems in all IWComboBox descendants. You can call it in Async so it will refresh completely:

I had forgot about that method. I use it in TIWDBGrid. If you make it automatic, let me know. I haven't thought through why/if it might have a downside being auto but I can't think of a downside offhand.

Dan

Hi Dan,

it used to be "automatic", i.e. all combo box was refreshed every time you changed selected item. It means that, if you have a huge combo, say, 1000 items, your Ajax response would be huge and performance suffers. However, I think we can make it automatic in this specific case.

Yea, a DBGrid would probably get several times the hit as a combobox.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02