PDA

View Full Version : combobox --> SQL dataprovider from Grid --> loop??


MadamZuZu
06-27-2008, 03:15 PM
Hi,

i'm using a datagrid whichi populates from a sql databse, via coldfusion.

when datagrid is clicked, i need to populate the combobox, the issue is, the database does not have valid index numbers for the data that should go into a combobox, and i can't populate it using the selectedItem...

as i understand, i need to somehow loop around the dataprovider, and get the index numbers?



for(vari:int =0; i <= delds.length; i++)
{
trace( ObjectUtil.toString(item) ); //this gives me ALL objects, not just the current one.
.//index+1 untill i dataprovider name is equals to the selected item on the datagrid.
}




*delds - is my dataprovider name.

i dont understand, how do i reference dataprovider items, one by one, untill it matches up with that one selected from the datagrid?

please help

Thanks!


or am i doing this all wrong?

bdover28
06-27-2008, 03:24 PM
you can assign dataproviders to combo boxes as well, onclick event for your DG


onClick="myComboBox.dataProvider=myDataGrid.dataProvider"


then you can assign a labelField and dataField iirc.

don't know if that helps... you may want to look at the selectedItem and selectedIndex references on both the DG and combo box. Are you trying to fill the combo box with info from the whole DG or info from the selected item in the dg or what?

MadamZuZu
06-27-2008, 03:33 PM
from the selected column only. for example, i have a few items, which contain proper index numbers, i populate them like so:




cmbPII.selectedIndex = dgGrid.selectedItem.PII;



but when it comes to objects, witout a index - i can't assign by selectedItem, i think i have to create my own Indexes for them.

i can't just find a way to do it....

does taht make sense?

bdover28
06-27-2008, 03:36 PM
yeah.. not sure how to help with that

MadamZuZu
06-27-2008, 03:51 PM
i think i'm almost there, u'm using



trace( ObjectUtil.toString(item));



to compare to the datagrid selected item, but the output of trace( ObjectUtil.toString(item)); is

(Object)#0
Source = "CBS"

how do i strip it, so i only have CBS showing?

MadamZuZu
06-27-2008, 04:34 PM
i figured it out, if anyone is interested, this is mycode:





for each( var item:Object in delsm )
{
if(dgGrid.selectedItem.Name == item.Name)
{
cmbSM.selectedIndex=i;
}
else
{
i++;
}
}