-
1. Re: Blank ComboBox
Flex harUI Mar 9, 2011 1:00 PM (in response to cortlander1)I noticed you are binding the text of the combobox to something. If that
thing becomes blank, then the combobox will be blank
-
2. Re: Blank ComboBox
cortlander1 Mar 9, 2011 1:49 PM (in response to Flex harUI)Thanks, Alex. But I do not see anything in the dataTypeSelection binding that could turn blank, it is a fixed array.
[Bindable]
public var dataTypeSelection:ArrayCollection = new ArrayCollection(
[ {label:"string"},
{label:"boolean"},
{label:"integer"},
{label:"double"},
{label:"dateTime"},
{label:"date"},
{label:"time"},
{label:"hexBinary"},
{label:"base64Binary"},
{label:"anyURI"},
{label:"x500Name"},
{label:"rfc822Name"},
{label:"ipAddress"},
{label:"dnsName"} ]);
Regards. -
3. Re: Blank ComboBox
bmleite Mar 9, 2011 3:18 PM (in response to cortlander1)Hi,
I cannot reproduce the problem, I've tried different code combinations but I always get the same result... the right one =)
Can you please provide some (more) code which we can use to reproduce the issue?
I have an idea what might be causing the problem, but I need to confirm it first otherwise I could be misleading you.
-
4. Re: Blank ComboBox
cortlander1 Mar 9, 2011 5:35 PM (in response to bmleite)bmleite, thanks for responding.
I have so many combo boxes in several applications, and this is happening in every one of them.
Here is another one:
<mx:Script>
...
[Bindable]
public var targetTypeSelection:ArrayCollection = new ArrayCollection(
[ {label:"subject"},
{label:"resource"},
{label:"env"},
{label:"action"} ]);
...
</mxScript>
...
<mx:Form>
...
<mx:ComboBox id="txTargetType" text="{dgTargetType.selectedItem.targetType}"
dataProvider="{targetTypeSelection}" labelField="label"
selectedIndex="0" editable="false"/>
...
</mxForm>
On the first pass, say I clicked on 'resource'. Everything is fine.
I save the form and start a new record and revisit the dropdown. When I click on the dropdown,
the 'resource' item is highlighted. But if I select it, nothing shows
in the field. If I change the selection to say 'env' that does
display in the field. Now, if I dropdown again and select 'resource'
it does show up. So, to get 'resource' I first had to change the value
to something else and then change it back to 'resource'.
When I revisit this dropdown again, it remembers my last selection and that item
is highlighted in the dropdown, but if I pick it, the field will show a BLANK
unless I change to some other selection first.
Here is another example with again the same issues - and I have many of these:
[Bindable]
public var combAlgSelection:ArrayCollection = new ArrayCollection(
[ {label:"deny-overrides"},
{label:"permit-overrides"},
{label:"first-applicable"},
{label:"only-one-applicable"} ]);
....
<mx:Form>
...
<mx:FormItem label="Policy Comb. Alg.: " required="false">
<mx:ComboBox id="txPolicyCombAlg" text="{dgPolicySet.selectedItem.policyCombAlg}"
dataProvider="{combAlgSelection}" labelField="label" prompt="Select algorithm:" width="150"
editable="false" selectedIndex="-1" />
</mx:FormItem>
</mx:Form>
I have struggled with this for a long time, and any assistance would be most appreciated.
Thank you.
-
5. Re: Blank ComboBox
Flex harUI Mar 9, 2011 9:24 PM (in response to cortlander1)It isn't that binding that is the issue, it is the binding to the text
property from dgTargetType...
You have not shown how that relates to interacting with the ComboBox
-
6. Re: Blank ComboBox
cortlander1 Mar 10, 2011 1:16 PM (in response to Flex harUI)Sorry, I misunderstood.
This comboBox is in a module and the main class has remote services
which use BlazeDS to send data to the database. The module
actually implements an interface.
dgTargetType is a datagrid populated by a variable _targetTypes which
is obtained from a remote call using a service in the main form:
[Bindable]
private var _targetTypes:ArrayCollection = new ArrayCollection();
(has getter, setter implementing interface property)
<mx:DataGrid id="dgTargetType" rowCount="10" dataProvider="{_targetTypes}"
itemClick="targetTypeItemClickEvent(event);" height="100%" width="100%" >
<mx:columns>
<mx:DataGridColumn color="0x0050AA" dataField="targetType" headerText="Target Category"/>
</mx:columns>
</mx:DataGrid>
Upon doing a save, the text property of the combo is stored in an object
for sending to the database.
targetType.targetType = this.txTargetType.text;
Upon clicking on "New" button the form is cleared thus:
private function newTargetType():void {
// clear data in form without removing binding
if (dgTargetType != null)
dgTargetType.selectedIndex = -1;
... etc
Not sure if this gives the information you were looking for?
Thank you.
-
7. Re: Blank ComboBox
Flex harUI Mar 11, 2011 1:17 AM (in response to cortlander1)Hard to say, but setting dgTargetType.selectedIndex to -1 makes
dgTargetType.selectedItem become null so the text of the ComboBox should
show nothing.
-
8. Re: Blank ComboBox
cortlander1 Mar 11, 2011 10:08 AM (in response to Flex harUI)Yes, it does show nothing, which is what I intended, since I clicked on "New" and am starting to add a new record and do want everything in the form clear.
But in the drop down, even though selectedIndex property is set to -1, it somehow not only defaults to the last chosen value, but if that is picked, the text in the drop down shows a blank.
However, playing with this, a hack works.
Added a close event:
private function dropPolicySetEvent(event:DropdownEvent):void {
if (newMode)
event.currentTarget.selectedIndex = -1;
}
<mx:ComboBox id="txPolicyCombAlg" text="{dgPolicySet.selectedItem.policyCombAlg}"
dataProvider="{combAlgSelection}" labelField="label" width="150"
editable="false" open="dropPolicySetEvent(event)" />
Now when I click on the drop down, nothing is highlighted, and I can pick whatever, and it does show in the text area. I am puzzled why selectedIndex set to -1 in the combo box does not register, but it does work through the close event code. Perhaps there is a better way? -
9. Re: Blank ComboBox
curtis33321 Mar 11, 2011 10:17 AM (in response to cortlander1)Rather than binding the text I would tie to the event on the datagrid when the user selects a different row. Then instead of setting the text value, set the selectedindex. That way you let the combo box do what it really is designed to do which is serve values from a specific location in the collection of it's dataprovider. Right now you are short-circuiting the index changes which is causing yoru text to be unpredictable (or predictably not right).
-
10. Re: Blank ComboBox
cortlander1 Mar 11, 2011 12:59 PM (in response to curtis33321)Thanks for the suggestions, Curtis.
In this particular example, the comboBox is non-editable, but in many other instances it is editable. We have situations where we need to allow values other than those in the combo. So, I am unable to set it to the dataprovider's selectedIndex.
The values from the datagrid are behaving as expected, but I ran into the problem when I am entering a new record through the form. At this point, the datagrid selectedIndex is set to -1 to unlink it from the form. Now I am looking for a fresh value from the combo, but for some reason, the drop down always highlights the last picked value.
Regards.
-
11. Re: Blank ComboBox
curtis33321 Mar 11, 2011 1:22 PM (in response to cortlander1)Well if it is after you are modifying the dataProvider then I'll share a bug we found in comboBox. If you change the dataProvider of the comboBox, it has a tendancy in certain situations to blank out. So, to avoid this we also set the comboBox.dropdown.dataProvider to the same thing and that ensures that everything is sync'd back up.
You might want to give that a shot.
-
12. Re: Blank ComboBox
Flex harUI Mar 11, 2011 1:47 PM (in response to curtis33321)That is a bug in 3.5. Should be ok in Flex 4.
-
13. Re: Blank ComboBox
cortlander1 Mar 11, 2011 1:48 PM (in response to curtis33321)Curtis, I am not sure I follow:
"set the comboBox.dropdown.dataProvider to the same thing"?
Could you please elaborate? Thanks.
I am not really changing the dataProvider to the combo. It is just that once a value has been selected, the next time I try to add a new item, the same value is highlighted. And if I select that highlighted value, a blank shows up. If I pick any other value, no problem. It also seems that the selectedIndex=-1 is not being set (since a value is highlighted). But if I set selectedIndex=-1 in a DropDownEvent it works as expected. That is what I ended up hacking.
Regards.
-
14. Re: Blank ComboBox
curtis33321 Mar 11, 2011 2:18 PM (in response to cortlander1)I just read your code an a previous post again and have to say you should ignore my previous post. It isn't addressing your issue, but a different one.
It does look like you are using an older framework with mx:Script and mx:ComboBox. If the issue comes up when you go to add a new item and are resetting the form control values, I would ensure at the time you set it into that mode to set all of the indexes to -1. There were inconsistencies with ComboBox that we had to overcome I would have to see more code to give a concrete answer. You should be able to duplicate the datagrid's dataprovider with a local collection and put together an "offline" sample we can play with. There are 4 potential sources of the text value:
- if it is editable, then user input
- it is bound to a dg element
- the dataprovider has label element
- you have a prompt setup
I definitely need to see more to make sure I don't lead you down a rabbit hole.
-
15. Re: Blank ComboBox
cortlander1 Mar 12, 2011 10:41 AM (in response to curtis33321)Curtis, thank you for taking the time to respond.
I did build a test script. Is there a way to attach a file to this post?
It has a datagrid, and two forms.
All combo boxes have selectedIndex property set to -1, no prompts,
and are editable.
The Good Target side works as
expected. The combo box has an open method which sets selectedIndex=-1
The Bad Target side has an issue.
1. Click on '2' in the grid and 'resource' appears in the combo.
2. Select 'env' from the dropdown and do Save
3. Alert box shows 'env' as the text in the combo, and index=2 for the
third record.
Fine so far.
4. Click 'New' and all is blank
5 open the combo, and 'env', which was the last selected value,
is displayed highlighted
6. Select the highlighted 'env' and nothing shows in the combo
7. Hit Save, and the Alert shows index=2 was picked correctly, but the
text property was blank
8. Click 'New' again, and instead of the highlighted 'env' pick any
other value and the text property is assigned and displayed as expected.
Thank you.



