Jun 3
Indent issue with Hierarchical Data and DataGrid ItemRenderer
Today I was trying to create a DataGridColumn Item renderer that would set the background color based on the data in the column. Usually this is a simple thing to do, you would just created and ItemRenderer that extends Label and then set the background color to whatever you want.
The problem I ran into was that my data was Hierarchical, and when you create an Item renderer that extends Label for Hierarchical data you lose the “Parent” “Child” indentation for each leaf node. After messing around for a bit I found a solution which I thought I would share.
Inside the ItemRenderer you have access to a item called listData which is of type AdvancedDataGridListData. This object has a property called indent which refers to the actual number of pixels this item should be indented based on its position in the tree. To set the indentation for the text inside the label all you have to do it create a variable which is bound to the paddingLeft property of the Label. Then inside the updateDisplayList method set the variable to the indent property passed in from the AdvancedDataGridListData.
Pretty simple solution. Would love to know if anyone has solved this problem another way!
No Comments
Leave a comment