Flex:how to disable particular item in combobox? - apache-flex

I have ComboBox With ArrayCollection as DataProvider. Data will come from Databse as ArrayCollection. I'm Adding Item to ArrayCollection "-Select Item-" at 0th index and setting selected index=0 for combobox.
My question is How to disable that(-select Course-) item?

I recommend you to use prompt property of DropDownList or ComboBox for that and combine it with selectedIndex = -1 as initial value.

Worst case an item renderer to show things as disabled. Then simply ignore the click if it has the property disabled. (this implies your list is overloaded with a property like isDisabled.
Mylist.selctedItem.isDisabled

Related

flex list with itemRenderer

I have a simple list bounded to an ArrayCollection and an itemRenderer
When I add a new item to the ArrayCollection, I get the event addedToStage: FINE
Trouble is when I remove an item from the ArrayCollection, I never events :
I tried:
remove, removed, removedFromStage and I need to stop a stream when the items is removed:
So HOW can I get an event when an ITEM is REMOVED ?
Thanks
Thing is item renderers are recycled. So when you remove the item from your collection, the item renderer is not destroyed, it's just given another data.
You can add an event listener on the dataChange event or override the set data function.
What are your tring to do exactly?
You should listen to the ArrayCollection events if you want to know if the ArrayCollection instance is changed. But I'm not sure what you are trying to accomplish. If you remove an item from the ArrayCollection then you should know that it is removed. Why or where do you need an event?

flex : add checkbox to datagrid control

i have a datagrid in my flex application, i am binding datagrid with arrayCollection,
now i want to add checkbox control to datagrid column and i dont want to bind chekcbox to arraycollection values.
i want something like this
without binding checkbox column field with arryayCollection.
Write an itemRenderer which is a checkBox, and handle change event. On change, set a property in the data to the selected boolean. Ex: data.rowIsSelected = checkBox.selected; The property does not need to already exist in the dataProvider.
Override set data property, and specify the check box's selected property to be the same as data.isRowSelected.
Later on, you can loop through the data set and get each item in the dataProvider's isRowSelected property to see if user had selected it or not.

flex 3 combobox selected item

I have a combobox with arrayCollection dataprovider, it has nothing selected after creation. I want to add some text as first option when nothing is selected, just to indicate that the user didn't select an option yet.
If I understood you correctly, prompt property is what you are looking for. To quote the ComboBox documentation from Flex 3:
The prompt for the ComboBox control. A prompt is a String that is displayed in the TextInput portion of the ComboBox when selectedIndex = -1. It is usually a String like "Select one...". If there is no prompt, the ComboBox control sets selectedIndex to 0 and displays the first item in the dataProvider.
Quote from ComboBox documentation

Adobe Flex Combobox as itemrenderer

I have a flex combobox as a datagrid itemEditor.
However, after selecting an item in the combobox, its necessary to click out of the combo (i.e. into another cell or elsewhere in the app) for the value to be committed to the combo. Prior to this, the combo sits 'proud' of the datagrid and the value hasnt actually been committed.
Is there a way to force the value to be immediately committed after an item has been selected and for the combo to 'lose focus'?
Ahh, so easy.
this.parentDocument.setFocus();

Flex Combobox - Edit/Delete an option

I'm using a combo box control and the dataprovider is set as an XML.
After the dataprovider is set, I want to edit the text of the first option and also I need to insert an item in the second position.
How can I do this? Using an ItemRenderer?
Please give your suggestions.
You should edit the dataProvider itself. Make it an ArrayCollection (or something else that implements IList) and your combobox will automatically update as you make changes. Also make sure that the array collection is full of bindable objects.
Changing ArrayCollection is easy. You can just say dataProvider.getItemAt(0).labelProperty = "whatever" -- this assumes you have an object with a property of "labelProperty" and your combobox's labelField is set to it.
To add an item just use dataProvider.addItemAt(item, 1)

Resources