This is very hammered code but may be serve for another person in the
future:

Inside my DataGridItemRenderer that extends from Royale
DataGridItemRenderer:
override public function set labelField(value:String):void
{
super.labelField = value;

if (!(getDataGrid().columns[_columnIndex] as DataGridColumn).visible)
{
((getDataGrid().view as DataGridView).header as
DataGridButtonBar).getElementAt(_columnIndex).element.style.display = "none"
;
(this.parent as DataGridColumnList).element.style.display = "none";
}
}

private function getDataGrid():DataGrid
{
return ((this.parent as DataGridColumnList).parent as
DataGridListArea).parent as DataGrid;
}

My ItemRenderer knows the columnIndex, so I use labelField as a way to
check the visible property from the DataGridColumn to hide the column
header(it's a button) the column (it's a list)

This is far away from the ideal standard code but honestly after countless
hours I came to this working solution for me.
If I find a better way in the near future, I will share.

I tried to put this code inside DataGrid in a more generic way and without
depending on a columnIndex but the far I could go was to hide the column
but never the button header. I believe that it's because the method runs
too soon but in Royale there are very few life cycle methods to catch the
controls behaviour.

Hugo Ferreira <hferreira...@gmail.com> escreveu no dia segunda, 15/11/2021
à(s) 00:19:

> In fact, seems that was not implemented (from DataGridColumn.as):
>
> public function set visible(value:Boolean):void{
> if (value != _visible) {
> _visible = value;
> //somehow, invalidate layout
> }
> }
>
> Hugo Ferreira <hferreira...@gmail.com> escreveu no dia segunda,
> 15/11/2021 à(s) 00:13:
>
>> Hi,
>>
>> I have a DataGrid with several columns and I need to hide a few of them
>> depend of the business logic.
>> It seems that the visible property (that exists) in the DataGridColumn is
>> ignored, even with the direct "false" value.
>>
>> Do I missing something or it's a property that exists but it's not
>> implemented the action?
>>
>> Regards,
>> Hugo.
>>
>

Reply via email to