This content has been marked as final. Show 6 replies
When you assign a custom itemRenderer for a column in DataGrid, property named "data" will be assigned the object (item node in your XML) corresponding that particular row in the DataGrid. So in your item renderer you can override this property setter function and do required computation. Please find sample code attached code. In the sample below in the item renderer, which is a Button component; I am setting the Button label to value in the "status" node of the XML.
Hope this helps.
Thanks SujitG - that is very useful to know :)
I have one final query which an example would really help to solve... What if I wanted to show a simple label if the status were 1, or a button if the status were 2, how would I go about doing this? Basically, the status is going to determine what visual control I show in the cell.
Many thanks for all your help.
Use an HTTPService to load the data, and instead of using lastResult use ResultEvent. In the result handler check the status value of each row and set the itemRenderer for each cell of each row.
Having said this, it is possible an item renderer can only be set on a column as a whole, not differently on cells in each row in a column.
Hi Greg, thanks for the reply... I am a bit of a newbie to flex - would you be able to provide a bit of sample code, or point me in the direction to where I can find some sample code that will do what you suggested? This is basically my function that i have called on the result of the httpservice...
private function PopulateDataGrid(event:ResultEvent):void
myDataXml = event.result as XML;
myData = myDataXml.item;
How would I modify this to do an "if the status is X, then show itemRenderer of XYZ, else if the status is Y, then show an itemRenderer of 123 on the column of the datagrid with ID = "StatusCell" and dataField="status"?
many thanks and sorry for the nuubiness of my questions.
I'm thrilled I actually got this to work. Hope it is of practical use to you, or gets you started:
Greg that is perfect- thank u!