incrementing the number of times a list component is clicked? - apache-flex

I have a list component that lists certain items..
so, if i click on a certain item..i should get the index this way :
var clickedIndex:int = listID.selectedIndex;
but how can i count the number of times the variable clickedIndex has been selected?
so, if a user keeps clicking on the index[0], i want to know how many

A couple ideas off the top of my head (I'm assuming your List dataProvider is an ArrayCollection):
Modify the Object you're using in the ArrayCollection for your list's dataProvider to include a clickCount property. When an item is selected in the list, increment the clickCount property. This will keep the correct number of clicks for each item if your ArrayCollection gets sorted or filtered and the indexes change.
Create an Array variable to store the click counts for each index in your ArrayCollection. Then you would increment the number the the Array's index that matches the ArrayCollection's selectedIndex.

Related

How to capture removed item in AsyncTypeahead when removing item from the list

bootstrap-typeahead for add multiple items to a list.
https://github.com/ericgio/react-bootstrap-typeahead
I need to pick the value, when I remove an item from the list.
onChange event of the AsyncTypeahead handling the event when removing and adding items to the list.
When an item removed, selected data updating with the existing values in the list.
Eg: I have 3 items in the list, I am removing an item, Then the selected list containing existing items. (2 items)
In my project I want to get that removed item, at the time of removing.
Is there any functionality for pick that removed value in "onChange" event.
I had the same problem, and I get it sorted in this way:
Compare your current selected items with the selected items that you had before onchange.
eg:
const removedItem = this.state.alradySelectedItems.filter(value => !selected.includes(value));

Why there is no find item to get a unique item in QTreeWidget?

I have unique QTreeWidgetItems in QTreeWidget, I am using findItems() to find a specific item, it returns list of items. From this list taking the first item and storing in QTreeWidgetItem. but i wonder is there any method to find an item which returns only one item, if found ?

how get item from each cell in grid

I have form with grid. I defined dataStore with 2 columns (text and checkBox). Grid.store = defined dataStore. Second column is editable (you can change selection on each checkBox). I have some button, and when I click it, I want to get info about each cell. Example if have gird:
Name1 true
Name2 false
I want get info col[0].row[0] is equal 'Name1', col[0].row[1] is equal 'Name2'.
I try iterate on dataStore but it has only value which I put them by hand. The value which was changed on grid by clicking on checkBox didn't save in dataStore.. My question is how to iterate on grid, how get info about each cell.
To iterate across a store in Ext3, you can use dataStore.each()
Supply it an anonymous function and the parameter it receives will be the current record in the store. The data in the current record can be read by using record_var.get(field_name).
So, for example:
var dataStore = myGrid.getStore();
dataStore.each(function(rec){
alert(rec.get(field1));
}

Flex Datagrid insert row below current row

my application needs to allow users to insert rows below the current datagrid row. My solution is to to add a row to the dataproviders collection. This works, but the row does not appear beneath the current row the user clicked on.
The Datagrid has a default sort order (date ASC), which re-orders the data...so this seems to affect the position of the row in the grid.
Any ideas how to fix this?
Two possible answers:
1. define your own sort function that sorts according to item order in dataprovider (i.e. it does nothing), and assign it to the sortFunction property
2. simply comment out the sorting of the data inside the component.

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.

Resources