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.
Related
I am working on old webform asp.net application which uses Repeater.
The Repeater is a set of Name and address textbox fields. I have 3 sets of Name and Address information, basically, 3 sets of records in the object list to bind.
On the UI, I changed/update one of the Name and Address. I noticed in the list, which it iterate or loops through the repeater control
foreach (RepeaterItem item in this.NameAddressRepeaterControl.Items)
I see that an extra recod is added to the items.
Question:
I am used to fixed textboxes. When I update the textbox, I write code to take Exactly what is filled in the textbox and populate the DTO object to pass to the data layer to perform database transaction to update the database records.
When the new updated record is added to the Repeater Control list, I don't know which records is updated and which is the new records.
I am checking out OnItemDataBound and OnItemCommand to see if there is a way to get the old value from one of the field and also record the value of the new value. Is this possible?
The form contains 1 Save button and it will loop through the Repeater.Items to see what Name/Address to extract, but the new and old company exist in this list.
Instead of looping through the RepeaterControl.Items, Is there a way to extract from directly the visible Repeater control? If there are 3 repeater Name/Address control, is there a way to get all the info from each of the 3 sets of Repeater controls? The Repeater wraps around a user control, NameAddressCtrl.
I prefer not to replace the Repeater controls with fixed textboxes.
Any help is greatly appreciated.
Thanks.
I reviewed the code several time and add additional code to keep track what was add and changed in the repeated and only passed the information to be saved to the db. The solution was to write additional code. I did not change anything with the repeater behavior. Thanks for the comments and help.
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 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.
I have data model (dataProvider as ArrayCollection) i want to display in few views , each view should show filtered data.
As you probably know, filterFunction is property of ArrayCollection,so I can't use this solution (unless creating new instance of ArrayCollection for each view on top original and impementing filterFunction).
Are there better approaches ?
Thanks
you can use ListCollectionView for each view that use your array, and every time you can pass to it the same array but filtered differently as source...
You're using the same ArrayCollection as dataProvider across multiple views, and setting the filterFunction in view1 persists into view2?
You could probably put code to change the filterFunction for each view in that view's "show" event. If you wanted to default each view to be unfiltered, pass in a function that just returns true.
i’m new to RIA, Flex.
Currently i’m using Flex 3.
I have some difficulty in my work.
i have three lists and a button.
depending up on the selected items in first two list and after clicking the button i have to disply the items in details list.can any any one help me
thanks in advance
in first list iam displaying names of employees
in second list displaying managers names
then if i select one employee name and one managers name then after clicking button corresponding employee and managers details should be dispplayed in the third list.
this is my work
presently iam unable to post my code
the problem is with initialising the details list and dynamically changing it.
It sounds like your third "list" isn't going to be a list at all, it will be a DataGrid of some kind, or a form with key/value pairs for the common data each employee and manager share.
Presumably your employee and manager lists are populated from a database, and you get more data than the name with each data object. What you need to do is add an event listener which listens for the change event in each of your first two lists. Then you have an event handler that does something with the result. The following just concatenates all the data from each selectedItem (for our imaginary list1 and list2) and puts it into an ArrayCollection, which is then assigned as the dataProvider for a DataGrid named dg:
private function changeHandler(event:DataGridEvent) : void {
var list1Item:Object = list1.selectedItem;
var list2Item:Object = list2.selectedItem;
var ac:ArrayCollection = new ArrayCollection();
for (prop in list1Item) {
ac.addItem({prop:list1Item[prop]});
}
for (prop in list2Item) {
ac.addItem({prop:list2Item[prop]});
}
dg.dataProvider = ac;
}
This is obviously not how you are going to do this, but it serves as an example. More likely you will have certain properties that you are interested in showing, and those are the ones you will add to the dg dataProvider.
This is as helpful as I can be speaking generally, in the absence of specific descriptions and requirements.