How to get rid of already selected items in combobox - apache-flex

Am having an issue with combobox duplications
i have 10 autocomplete comboboxes with all having same dataprovider...
suppose like this array collection
public var costCenter:ArrayCollection = new
ArrayCollection(["1101","1111","1121","1131","1141","1151",
"1161","1171","1181","1191"]);
if 1st combobox is selected with 1131 then that shouldnt be there in next comboboxes dataprovider.
that is already selected items should be removed from collection for dataprovider
and user can select 1st any of the 10 comboboxes
am making a copy of collection and using that collection as dataprovider for all comboboxes..
how to remove the already selected items from collection?
any ideas?
Thanks.

You can use filterFunction on you ArrayCollection instances and call refresh() on them after selecting values. But all the collections should be different instances from the single Array as a source.

The best way to do it is to remove the items from selectedIndices if you are doing version 3.x then you can just do something like comboBox.selectedIndex = -1, but in 4.x you have to do something like comboBox.selectedIndices = new Vector.<int>().

Related

Flex - ComboBox labelFunction Not Refreshing With Updating of an ArrayCollection

I have two issues with my ComboBox.
My first issue is that when my ArrayCollection only has one item, for some reason I cannot select that first item. The change function set on the mxml never gets called when I try to select that one item. If I set a prompt, it works. I know that the item is not already selected because when debugging, the selected item shows null. I do not want to use a prompt. I want the first item in the ArrayCollection to be selected automatically. So if there is only one item, I want the selected item to be that. FYI - I am using a labelFunction to format the data in the Array Collection. Any idea why I cannot select the first item or set the first item in the ArrayCollection to be the selected item?
My bigger issue is that when my Array Collection gets updated, my label function must not be refreshing because when I first open the dropdown, it has specfic data. When the Array Collection gets updated and I open the dropdown again, I see the old data in the dropdown, yet it doesn't exist anymore.
So let's say I have a ComboBox that has a datasource of an array collection of one state code and it's state name. Their is a labelFunction that puts a dash in between the state code and the state name. Their is no prompt, so the ComboBox would look like GA - Georgia and when you open the dropdown, that would be all that is there. I want that item to be selected automatically. Any idea why the old data shows up when opening the dropdown after the array collection was updated with new data?
<mx:ComboBox labelFunction="getFormattedNpaNxxCollectionList()"
dataProvider="arrayColl" change="doSomething()"/>
public function getFormattedNpaNxxCollectionList(item:Object):String
{
return StringUtil.substitute("{0} - {1}", item.stateCode, item.stateName);
}
Is the arrayColl declared as [Bindable] - the updates won't be reflected automatically if its not bindable. Post the code where you're updating the collection.
To select the first item if there's just one item after updating the array collection, you can call
if(arrayColl.length == 1)
cb.selectedIndex = 0;
after the update.
If you are only updating the values in the collection (and not reassigning a whole new array collection object to arrayColl), you can do this from the collectionChange event handler of the array collection. Otherwise you have to do this after assigning the new collection object to the arrayColl variable.

flex datagrid: how to do a multiple selection programmatically

I have I datagrid, on which I want to select multiple rows on a other user interaction than the one intended by the Programm. I'm wondering, whether I can programmatically select some rows depending only on code?
Thanks,
Markus
You can set the selectedIndices property to an array of indexes, or the selectedItems property to an array of items.
For example:
myDataGrid.selectedIndices = [1,2,5,8];

how to get all child itemvalues in list in flex3

i'm new for flex...
we can the length by using getnumber but
i want to get all item values in the list and to display the item values in the alert box one by one... is it possibile?
thank's
Can't you get them directly from your list's DataProvider (which might be an ArrayCollection or a XML object?)

flex datagrid - item renderers and skipping rows

HI,
I have a datagrid with 6 columns, each with its own item renderer. In the first column i want to be able do a check and see if the column contains some valid data, if not then i want to skip this row and go to the next. In other words i want a way to tell my datagrid to stop processing the rest of the item renderers for the current data object and skip to the next. Any ideas?
I'd say your best bet is to use the filterFunction property on ListCollectionView objects (such as ArrayCollection). This allows you to filter out the objects you don't want to show in your DataGrid before they're displayed in the grid, and should avoid any itemRenderers being processed altogether.
If you still want the "skipped" object to display in the data grid and just change how the item renderers respond to it, then you'll need to write code for that in the renderers.
Inside of the item renderer, you can access the data values of the previous columns. You should examine the listData property available in the item renderer and use your findings to configure how the item renderer should display.
You can find information about the listData here: http://livedocs.adobe.com/flex/3/langref/mx/controls/dataGridClasses/DataGridListData.html
To examine previous values, you might code something like this:
var dgListData:DataGridListData = DataGridListData( listData );
// Process all columns before the current one.
for ( var i:int = 0; i < dgListData.columnIndex; i++)
{
// Do something here to examine previous data
// If we should stop processing based on previous values
// then hide everything inside of this renderer (perhaps
// move to a state name 'empty' that has no children), else
// move to the state that renders something.
currentState = shouldSkipObject ? 'empty' : 'normal';
}
If you want more specific help writing the code inside of the item renderer, please include a sample of what the data looks like inside of the data grid as well as a description of what the item renderer should actually do.

How to get data from dynmically created Treeview

I am using ComponentArt Third party controls for ASP.NET 2.0.
Here is the problem I am facing.
I created some ComponentArt.Web.UI.TreeView at runtime on Page_Load.
Now at click event of a button, I want to get values of the selected nodes in the treeview.
Can someone help?
Firstly I'm assuming you have MultipleSelectEnabled set to true to allow the selection of multiple nodes in the TreeView.
If you have that you can use the MultipleSelectedNodes property of the TreeView to get an array of TreeViewNodes.
From here you just need to iterate through the array and use the Value property of the nodes to get what you need.
So essentially something like this should work,
TreeViewNodes[] selectedNodes = treeViewID.MultipleSelectedNodes;
ArrayList values = new ArrayList(selectedNodes.Count);
foreach (TreeViewNode node in selectedNodes) {
values.Add(node.Value);
}
And now you have your selected node values in the ArrayList.

Resources