PDA

View Full Version : passing variables to custom cellrenderer button


Flippie124
02-01-2005, 03:40 PM
hello,

I've created a custom cellrenderer button class. But I don't know how I can pass varibales to this class.

This is my setValue function. As you can see, I need to pass a variable (columnheaderfield) to this class which specifies the field of the item where the button is located. The problem is that I cannot hardcode the name of this field because field names are unknown and dynamically generated. So the second piece of code is how you can do this when you hardcode it.

function setValue(str:String, item:Object, sel:Boolean,columnheaderfield:String) : Void
{
btn._visible = (item!=undefined);
btn.label = item[columnheaderfield].label;
action = item[columnheaderfield].action;
id = item[columnheaderfield].id;
}


function setValue(str:String, item:Object, sel:Boolean) : Void
{
btn._visible = (item!=undefined);
btn.label = item.editfield.label;
action = item.editfield.action;
id = item.edit.id;
}

Flippie124
02-01-2005, 04:04 PM
OK... I've already found a solution :). If you want to trace the field of of the item where your button is located (from inside your custom cellrenderer class). You add the following code:

function setValue(str:String, item:Object, sel:Boolean,columnheaderfield:String) : Void{
var index = getCellIndex();
var column = listOwner.getColumnAt(index.columnIndex);
var columnheaderfield = column.columnName;
btn._visible = (item!=undefined);
btn.label = item[columnheaderfield].label;
}