Hi,
I have a grid with two combo boxes. So in order to use a common cell
renderer i have extended the Datagrid column to include a
dataProvider variable. I have created the common cell renderer. The
combos are populated from different arrays using the dataProvider
variable in the newly defined datagrid column
The data in the combo's get displayed correctlt but if i select a
particular value in a combo in row 1 and then move the mouse
randomly over the combos in same column in other rows, the value in
the other rows chnages to the value i had previously selected in row
1.
I have been trying to solve this for some time nad would like some
expert advise...
This is my cell renderer code.. can any one please tell where the
error is?
import mx.core.UIComponent
import mx.controls.ComboBox;
import mx.utils.ArrayUtil;
import mx.controls.DataGrid;
class NewComboRenderer extends UIComponent
{
var combo : MovieClip;
var listOwner : MovieClip; // the reference we receive to
the list
var getCellIndex : Function; // the function we receive from
the list
var getDataLabel : Function; // the function we receive from
the list
var isCellEditor : Boolean = true;
var columnOwner;
function createChildren(Void) : Void
{
//trace('createChildren combobox in grid');
createClassObject(ComboBox, "combo", 1,
{styleName:this, owner:this, selectable:true});
combo.addEventListener("change", this);
size();
}
function size(Void) : Void
{
combo.setSize(layoutWidth,layoutHeight);
}
function setValue(str:String, item:Object, sel:Boolean) :
Void
{
combo.visible = (item!=undefined);
columnOwner = ComboDatagridColumn(DataGrid
(listOwner).columns[getCellIndex().columnIndex]);
trace("columnOwner.headerText"+columnOwner
[getCellIndex().itemIndex]);
var arr:Array = ArrayUtil.toArray
(columnOwner.dataProvider);
combo.dataProvider = columnOwner.dataProvider;
if (columnOwner.dataProvider.selectedIndex!=
undefined){
combo.selectedIndex =
columnOwner.dataProvider.selectedIndex;
}
}
function getPreferredHeight(Void) : Number
{
return 21;
}
function getPreferredWidth(Void) : Number
{
return 150; // be more realistic
}
function handleEvent(evt:Object):Void
{
trace("change");
if (evt.type == "change")
{
var colName = listOwner.getColumnAt(
getCellIndex().columnIndex ).columnName;
trace("colName"+colName);
// update the row's comboData.selectedIndex
with that of selectedIndex of
// the combo box
trace
("combo.selectedIndex"+combo.selectedIndex);
trace("getCellIndex().itemIndex"+getCellIndex
().itemIndex);
columnOwner.dataProvider.selectedIndex =
combo.selectedIndex;
// update the dataProvider to reflect this.
this will cause setValue() to
// be triggered again, which then uses the
comboData.selectedIndex to
// set the comboBox properly.
listOwner.editField(getCellIndex
().itemIndex,colName,combo.selectedIndex);
}
}
}
// ActionScript Document
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/