Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

binding combobox to dataset

Status
Not open for further replies.

jcaulder

Programmer
Apr 22, 2002
241
US
I have tried numerous approaches but can't seem to get a combobox correctly bound to a dataset.

The problem is that the combobox display value(label) does not change to match the currently selected record in the dataset. If I change the selection in the combobox, it does correctly update the dataset though.

Anyone know the correct way to bind a combobox to a dataset? My current binding that allows the update to occur but no synchronizing when changing records is:

binding ==> combobox.value<->dataset.field

Is there some other binding I need? Do I have to do something programmatically to accomplish this? All my other bindings have been done using the GUI so surely the combobox isn't different. I'm sure I could do something with the on(afterLoaded) of the dataset or on(cellPress) of the datagrid to force it to keep synch but that seems archaic compared to the other UI components.

Thx!

J
 
do you have a dataset or is it a datagrid? if you do have a dataset, what are the bindings between it and the datagrid?
 
I actually have both a dataset and datagrid on the form. The datagrid is bound to the dataset in the following way:

datagrid.dataProvider <-- dataset.dataProvider
datagrid.selectedIndex <--> dataset.selectedIndex

All of my other components are bound to the dataset and work fine. It's just the combobox that I have a problem with. The only options for databinding the combobox are:

value:String
dataProvider:Array
selectedIndex:Number
selectedItem:Object

If I bind the combobox.value to the dataset.field(which seems the most logical of the choices), navigating through the records in the datagrid does not change the value presented in the combobox to match the value in the dataset.

The combobox.dataProvider binding simply controls the label/data pairs that display in the combobox so I'm sure this should not be bound to the dataset.

The combobox.selectedIndex is a numeric value from 0 to combobox.length. Once again, there is nothing to bind this to because the index of the items in the combobox has no real relationship to the value in the dataset(i.e. the dataset.field = "Male" whereas the combobox.selectedIndex for the "Male" option is 0). And the dataset.selectedIndex is merely the index of the currently selected record and has no relationship to the combobox.selectedIndex.

Finally, the combobox.selectedItem which is an object. While there doesn't appear to be any way to graphically bind this to the dataset at design time, I have tried many methods to create a binding in code but they don't work either.

Hope this clarifies a little. I know there must be an easier way to do this.

For now, I have it working but only by writing code for the 'change' event of the datagrid and the 'result' event for the xmlconnector that loops through all the values in the combobox comparing them to the dataset.currentItem.value. When the match is found, I force that item to display in the combobox by using comboxbox.selectedIndex. This works but surely this is not the intended method to keep the combobox in synch with the dataset/datagrid current record.

Thanks!
 
Do you have an event listener for when the selection of the dataGrid changes?

If you have an event listener, you could bind whatever data you wanted to the combo box via actionscript, all depending on what the currentSelectedIndex is
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top