How do you get listData to a DataGrid itemRenderer?

I want to do simple reusable components in .mxml use in my dataGrid classes. I don't want to specify the data field because I could use the same rendering engine of several columns in the same grid (for example a converter box) and I don't want to make several identical components whose only difference is the value that they draw 'data. To do this, I need to access "listData. Specifically listData.dataField. According to the docs, I need to implement the mx.controls.listClasses.IDropInListRenderer. I tried the following in my mxml code:

< mx:Component id = "reusableEditor" >
< mx:HBox implements = "mx.controls.dataGridClasses.DataGridItemRenderer" >
import mx.controls.dataGridClasses
.. content and display logic data [listData.dataField]...
< / mx:HBox >
< / mx:Component >

"I get an unnecessary error in Flex Builder, saying that"an internal build error has occurred"and only guess now that it is the 'implements ="mx.controls.dataGridClasses.DataGridItemRenderer' line ' (when I delete this line, things work very well). I have not found anywhere to check if I implement this correctly because there is not an example of work that does what I want to do - even if I use DataGrid 100's of times more often than any other list class! The example of TreeRenderer later in the docs is the only code addressing this issue, but it is a class AS that does not (as far as I can tell) a container such as HBox and doesn't implement any interface.

Just how can the question, I have access to listData?

the tag was not the solution either...
I finally understood what the ambiguous compiler error means... I had not implemented the functions required for the interface. Here is the working code that is declared as a component internal or external .mxml file displays the value of the column without explicitly defining what is this value.

Although this component is very simple, it was very difficult to understand how to implement documentation... I hope someone from Adobe takes note.


http://www.Adobe.com/2006/mxml"layout ="absolute">

[Bindable]
public var dp:Array = [{num:2, bool:true}, {num:3, bool:false}];
]]>





Import mx.controls.listClasses.BaseListData;
Import mx.controls.dataGridClasses.DataGridListData;

private var _listData:DataGridListData;

[Bindable ("dataChange")]
public function get listData (): {BaseListData}
Return _listData;
}

public function set {listData(value:BaseListData):void}
_listData = DataGridListData (value);
}

override public function drawFocus(focused:Boolean):void {}
check.setFocus ();
}

override protected function updateDisplayList(unscaledWidth:Number,_unscaledHeight:Number):void {}
super.updateDisplayList (unscaledWidth, unscaledHeight);
If {(super.data)
var dgListData:DataGridListData = DataGridListData (listData);
for some reason, setting check.selected here translates into behaviour bug
Check.Selected = data [dgListData.dataField];
}
}

define a getter based on the "dataChange" event seems to update the value of the checkbox correctly when
clicked, decreed, sorting, etc...
In addition, doing it this way avoids those annoying "data binding will not be able to detect changes... blah blah"
[Bindable ("dataChange")]
public function get val (): Boolean {}
Return Boolean (data [_listData.dataField]);
}

]]>









If anyone has any suggestions or comments, please let me know... I'm still trying to figure the best way to do it.

Tags: Flex

Similar Questions

Maybe you are looking for