how to get all child itemvalues in list in flex3 - apache-flex

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?)

Related

How to get rid of already selected items in combobox

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>().

list flex : how to get the index of first visible element?

I have a simple list in Flex that is populated every N seconds by a dataprovider. My goal is to avoid scrolling the list after the dataprovider has been changed.
So, before I populate the list, I save the selectedIndex, and once the dataProvider is filled, I call:
list.selectedIndex = index;
list.scrollToIndex(index);
Trouble is that this moves the selected item of the list to the top.
The solution would be to get the index of the first element displayed in the list: but I have no idea on how to get that. Any clue?
Perhaps something like: list.getIndexFirstVisibleElement()
You haven't mentioned if you're using Flex 4, but if you are you might want to look into ensureIndexIsVisible.
You can find an example here: http://blog.flexexamples.com/2010/05/12/scrolling-to-a-specific-index-in-a-spark-list-control-in-flex-4/.

Flex dataGrid how to color empty rows?

My problem is that empty rows (if there are more rows that dataSource items then there are empty rows) look identical to rows binded to dataSource items which are empty (see the difference?).
The only way to know the difference is to hover over them with the mouse, and if they are empty there's no color change, otherwise there's the blue background of the selection..
I want to change the color or in some way hide empty rows, those that are not bound to a dataSource item.
How can I accomplish this?
You can format your DataGrid using ItemRenderer.
The itemRenderer is a display object that get the data from the data provider and display it in the grid.
Writing your own logic can help your specific data display in general. in this case, check for data on the ItemRenderer object creationComplete. it the data is null or empty - display a sign (or whatever).
See this link as reference:
http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/
Enjoy!
I'm not sure if this is exactly what you are looking for but I cut off my rows at the end of my dataprovider like this:
myGrid.rowCount = myDP.length();
This can of course be modified with some simple logic to have min, max, or if it's a data entry type of grid length()+1.

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.

flex air datagrid itemRenderer

I have a datagrid with custom itemRenderer. When I click in a cell, I get its reference. Now I would like to get the reference of the other column in the sae row.
e.g.
In the datagrid I have clicked in 4th column of the 3rd row, I am getting reference of it no problem in that. Now I would like to get the reference of 1st column of the same row i.e 3rd.
Is there a way?
Thanks.
Your custom item renderers should be data driven. In other words everything you care about should be on the renderer's "data" property. If you need to manipulate another cell, you should manipulate the data for the row, and the cell should update itself.
That's the reason you're having a hard time with that -- there isn't a good way to grab a reference to another cell. There are bad ways, but they're bad :)
don't know if I understand this completely correct but here goes...
put on your datagrid a click event
<mx:DataGrid id="myDatagrid" click="getValues()" dataProvider="{someArrayColl}"/>
let say the first column has the name: 'id_column'
between the script lines:
private function getValues():void{
var first_column_value:String = myDatagrid.selectedItem.id_column;
//if you want the entire row in 1 Array
var the_selected_row:Array = myDatagrid.selectedItem as Array;
}
haven't tested the array statement but it should work. myDatagrid.selectedItem is default an object of an arraycollection.
//you should put a try and catch statement in the getValues function to catch the exception when users click on a headeritem or the datagrid-scrollbar

Resources