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.
Related
I have a model with two fields, Name and Token. In my app, the user will select a record from a Dropdown populated with the Name field of all records. When this happens, I need to assign the record's corresponding Token value to a variable in a server script, but am not sure how to accomplish this.
There are two options that are suitable. As a first option you could implement a server script that returns the token of the field when you edit the widget.
function checkToken(widgetValue) {
var query = app.models.YourModel.newQuery();
query.filters.Field._equals = widgetValue;
var records = query.run();
return records[0].Token;
}
You can add the script caller checkToken(widget.value) to the onValueEdit event of widget, so that it runs every time you select another dropdown item. If you want to use another event, please look at https://developers.google.com/appmaker/ui/logic#events.
As a second option you could add a secondary label to your form which you bind to the dropdown item selection. The binding would look something like this:
#pages.MyPage.descendants.DropDown.value.Token
When you configure Dropdown you need to set three important properties:
options
An array of string representations of options that makes up the content of the dropdown
#datasources.MyDatasource.items..Token
names
An array of strings to be displayed in place of options' default strings. The array must be the same length as options.
#datasources.MyDatasource.items..Name
value
The value assigned to the databound property, based on the user's dropdown selection
// Assuming that dropdown is added to form
// or any other container bound to proper datasource.
#datasource.item.Token
Note
double dot .. syntax is used for projections
Event after updating the data model javafx treetableview cell value not getting updated.
I am using the sample code here # http://docs.oracle.com/javase/8/javafx/user-interface-tutorial/tree-table-view.htm
(Example 15-2)
On click of button i m trying to update first item: employees.get(0).setName("Test");
Is there any trick using which treetableview can be updated?
The example, somewhat strangely, returns a ReadOnlyStringWrapper wrapping the property values for the cell value factories. Thus instead of binding the value displayed in the column directly to the properties in the Employee class, it binds them to a new, read-only, property wrapping the value retrieved when updateItem(..) is called on the cell. This means it won't get updated when the underlying data is updated, but only if the updateItem(...) method is invoked on the cell. (I have no idea why they would do this.) So you should find, for example, that if you change the value, then collapse the root node in the TreeTableView and expand it again, that your new value is displayed after expanding the root (because this causes the cells' updateItem(...) methods to be invoked).
To make the cells update when the data is changed, bind the cell value directly to the property defined in the model (Employee) class:
empColumn.setCellValueFactory( param -> param.getValue().getValue().nameProperty());
and
emailColumn.setCellValueFactory( param -> param.getValue().getValue().emailProperty());
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.
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>().
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.