mx:advancedDataGridColumn labelFunction emulation with jewel datagrid

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

mx:advancedDataGridColumn labelFunction emulation with jewel datagrid

tranquiliste
Hello all,

with mx: AdvancedDatagridColumn, there were a labelFunction property which
allowed to execute a function on each value of a column. Is it possible and
how to do the same  with jewel DataGrid?
I want ot do somthing very simple to display '--' when value is empty or
null

Thanks
Nicolas



-----
Nicolas
--
Sent from: http://apache-royale-users.20374.n8.nabble.com/
Nicolas
Reply | Threaded
Open this post in threaded view
|

Re: mx:advancedDataGridColumn labelFunction emulation with jewel datagrid

Carlos Rovira-2
Hi Nicolas,

just added support for labelFunction in Jewel in List and DataGrid (globally and at column level).
Since this depends on the item renderer, for other components not using ListItemRenderer or DataGridItemRenderer we should implement it.

examples:

List:
<j:List width="100%" height="300" className="tableStyle"
labelField="label" selectedIndex="1"
dataProvider="{listModel.iconListData}">
<j:beads>
<js:LabelFunction labelFunction="formatLabel"/>
</j:beads>
</j:List>

private function formatLabel(item:Object):String {
return " - " + item.label;
}

DataGrid:

<j:DataGrid localId="dg1"
change="lb1.html = describeItem(event.target.selectedItem)"
initComplete="loadDataProvider(dg1)">
<!-- <j:beads> // you can use LabelFunction to affect all columns and renders
<js:LabelFunction labelFunction="formatLabel"/>
</j:beads> -->
<j:columns>
<j:DataGridColumn label="Title" dataField="title"/>
<j:DataGridColumn label="Sales" dataField="sales" labelFunction="formatLabel"/>
<!-- // or if you just need it in a concrete column declare just there like above this line-->
</j:columns>
</j:DataGrid>

import org.apache.royale.jewel.supportClasses.datagrid.IDataGridColumnList;

private function formatLabel(item:Product, column:IDataGridColumnList):String {
if (column.labelField == "sales")
return item.sales + " €";
return getLabelFromData(column, item);
}



HTH

Carlos


El mié., 5 ago. 2020 a las 17:52, tranquiliste (<[hidden email]>) escribió:
Hello all,

with mx: AdvancedDatagridColumn, there were a labelFunction property which
allowed to execute a function on each value of a column. Is it possible and
how to do the same  with jewel DataGrid?
I want ot do somthing very simple to display '--' when value is empty or
null

Thanks
Nicolas



-----
Nicolas
--
Sent from: http://apache-royale-users.20374.n8.nabble.com/


--