Re: [flexcoders] Re: Reuse a LabelFunction
Thank you Alex and Amy for clarification. Angelo From: Alex Harui aha...@adobe.com To: flexcoders@yahoogroups.com flexcoders@yahoogroups.com Sent: Fri, 16 April, 2010 22:51:20 Subject: Re: [flexcoders] Re: Reuse a LabelFunction Amy is saying you could write your function like this: private function labelFunctionTest( itm:Object, col:DataGridColumn) :String { return df.format(itm[ col.dataField] ); } Which is correct and probably the easiest way to go. If you want to subclass you would do something like this: public class AngeloDataGridColum n extends DataGridColumn { public function AngeloDataGridColum n() { labelFunction = labelFunctionTest; } private function labelFunctionTest( item:Object, col:DataGridColumn) :String { return owner.document. df.format( item[dataField] ); } } By subclassing you don’t have to assign the labelFunctions to the columns that need them. On 4/16/10 2:12 PM, Angelo Anolin angelo_anolin@ yahoo.com wrote: Hi Alex, Appreciate if you could show a little example. Thanks. Angelo From:Alex Harui aha...@adobe. com To: flexcod...@yahoogro ups.com flexcod...@yahoogro ups.com Sent: Fri, 16 April, 2010 12:29:57 Subject: Re: [flexcoders] Re: Reuse a LabelFunction If it were me, I would subclass DataGridColumn and add the labelfunction to the subclass. Then it has the DGC’s context like dataField to work with. On 4/16/10 7:40 AM, valdhor valdhorlists@ embarqmail. com wrote: If it were me, I would use an item renderer. --- In flexcod...@yahoogro ups.com mailto:flexcoders% 40yahoogroups. com mailto:flexcoders% 40yahoogroups. com , Angelo Anolin angelo_anolin@ ... wrote: Hi Amy, But as you can see in the function, I am specifying the Datafieldname from the object which was passed. How can I make it more generic so that I can re-use it in other datagrid columns? I hope you could provide some samples. thanks. Angelo _ _ __ From: Amy amyblankenship@ ... To: flexcod...@yahoogro ups.com mailto:flexcoders% 40yahoogroups. com mailto:flexcoders% 40yahoogroups. com Sent: Fri, 19 March, 2010 9:13:38 Subject: [flexcoders] Re: Reuse a LabelFunction  --- In flexcod...@yahoogro ups.com, Angelo Anolin angelo_anolin@ ... wrote: Hi FlexCoders, I have created a labelfunction which I use in my datagrid to format the display value. mx:DateFormatter id=df formatString= DD/MM/ / And this is the AS function private function labelFunctionTest( itm:Object, col:DataGridColumn) :String {    return df.format(itm. DataFieldNamefor Col1); } Is there a way so that I could reuse the same label function to other datagrid columns? As you can see from the script above, I am only using the function to Col1 for the datagrid. How would I be able to specify the datafield if I am going to reuse the same with other datagrid columns? That is what the DataGridColumn parameter is for. Look at its dataField property. HTH; Amy -- Alex Harui Flex SDK Team Adobe System, Inc. http://blogs. adobe.com/ aharui
Re: [flexcoders] Re: Reuse a LabelFunction
Hi Amy, But as you can see in the function, I am specifying the Datafieldname from the object which was passed. How can I make it more generic so that I can re-use it in other datagrid columns? I hope you could provide some samples. thanks. Angelo From: Amy amyblankens...@bellsouth.net To: flexcoders@yahoogroups.com Sent: Fri, 19 March, 2010 9:13:38 Subject: [flexcoders] Re: Reuse a LabelFunction --- In flexcod...@yahoogro ups.com, Angelo Anolin angelo_anolin@ ... wrote: Hi FlexCoders, I have created a labelfunction which I use in my datagrid to format the display value. mx:DateFormatter id=df formatString= DD/MM/ / And this is the AS function private function labelFunctionTest( itm:Object, col:DataGridColumn) :String { return df.format(itm. DataFieldNamefor Col1); } Is there a way so that I could reuse the same label function to other datagrid columns? As you can see from the script above, I am only using the function to Col1 for the datagrid. How would I be able to specify the datafield if I am going to reuse the same with other datagrid columns? That is what the DataGridColumn parameter is for. Look at its dataField property. HTH; Amy
Re: [flexcoders] Re: Reuse a LabelFunction
If it were me, I would subclass DataGridColumn and add the labelfunction to the subclass. Then it has the DGC’s context like dataField to work with. On 4/16/10 7:40 AM, valdhor valdhorli...@embarqmail.com wrote: If it were me, I would use an item renderer. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Angelo Anolin angelo_ano...@... wrote: Hi Amy, But as you can see in the function, I am specifying the Datafieldname from the object which was passed. How can I make it more generic so that I can re-use it in other datagrid columns? I hope you could provide some samples. thanks. Angelo From: Amy amyblankens...@... To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Sent: Fri, 19 March, 2010 9:13:38 Subject: [flexcoders] Re: Reuse a LabelFunction  --- In flexcod...@yahoogro ups.com, Angelo Anolin angelo_anolin@ ... wrote: Hi FlexCoders, I have created a labelfunction which I use in my datagrid to format the display value. mx:DateFormatter id=df formatString= DD/MM/ / And this is the AS function private function labelFunctionTest( itm:Object, col:DataGridColumn) :String {    return df.format(itm. DataFieldNamefor Col1); } Is there a way so that I could reuse the same label function to other datagrid columns? As you can see from the script above, I am only using the function to Col1 for the datagrid. How would I be able to specify the datafield if I am going to reuse the same with other datagrid columns? That is what the DataGridColumn parameter is for. Look at its dataField property. HTH; Amy -- Alex Harui Flex SDK Team Adobe System, Inc. http://blogs.adobe.com/aharui
Re: [flexcoders] Re: Reuse a LabelFunction
Hi Alex, Appreciate if you could show a little example. Thanks. Angelo From: Alex Harui aha...@adobe.com To: flexcoders@yahoogroups.com flexcoders@yahoogroups.com Sent: Fri, 16 April, 2010 12:29:57 Subject: Re: [flexcoders] Re: Reuse a LabelFunction If it were me, I would subclass DataGridColumn and add the labelfunction to the subclass. Then it has the DGC’s context like dataField to work with. On 4/16/10 7:40 AM, valdhor valdhorlists@ embarqmail. com wrote: If it were me, I would use an item renderer. --- In flexcod...@yahoogro ups.com mailto:flexcoders% 40yahoogroups. com , Angelo Anolin angelo_anolin@ ... wrote: Hi Amy, But as you can see in the function, I am specifying the Datafieldname from the object which was passed. How can I make it more generic so that I can re-use it in other datagrid columns? I hope you could provide some samples. thanks. Angelo _ _ __ From: Amy amyblankenship@ ... To: flexcod...@yahoogro ups.com mailto:flexcoders% 40yahoogroups. com Sent: Fri, 19 March, 2010 9:13:38 Subject: [flexcoders] Re: Reuse a LabelFunction  --- In flexcod...@yahoogro ups.com, Angelo Anolin angelo_anolin@ ... wrote: Hi FlexCoders, I have created a labelfunction which I use in my datagrid to format the display value. mx:DateFormatter id=df formatString= DD/MM/ / And this is the AS function private function labelFunctionTest( itm:Object, col:DataGridColumn) :String {    return df.format(itm. DataFieldNamefor Col1); } Is there a way so that I could reuse the same label function to other datagrid columns? As you can see from the script above, I am only using the function to Col1 for the datagrid. How would I be able to specify the datafield if I am going to reuse the same with other datagrid columns? That is what the DataGridColumn parameter is for. Look at its dataField property. HTH; Amy -- Alex Harui Flex SDK Team Adobe System, Inc. http://blogs. adobe.com/ aharui
Re: [flexcoders] Re: Reuse a LabelFunction
Amy is saying you could write your function like this: private function labelFunctionTest( itm:Object, col:DataGridColumn) :String { return df.format(itm[col.dataField]); } Which is correct and probably the easiest way to go. If you want to subclass you would do something like this: public class AngeloDataGridColumn extends DataGridColumn { public function AngeloDataGridColumn() { labelFunction = labelFunctionTest; } private function labelFunctionTest(item:Object, col:DataGridColumn):String { return owner.document.df.format(item[dataField]); } } By subclassing you don’t have to assign the labelFunctions to the columns that need them. On 4/16/10 2:12 PM, Angelo Anolin angelo_ano...@yahoo.com wrote: Hi Alex, Appreciate if you could show a little example. Thanks. Angelo From: Alex Harui aha...@adobe.com To: flexcoders@yahoogroups.com flexcoders@yahoogroups.com Sent: Fri, 16 April, 2010 12:29:57 Subject: Re: [flexcoders] Re: Reuse a LabelFunction If it were me, I would subclass DataGridColumn and add the labelfunction to the subclass. Then it has the DGC’s context like dataField to work with. On 4/16/10 7:40 AM, valdhor valdhorlists@ embarqmail. com wrote: If it were me, I would use an item renderer. --- In flexcod...@yahoogro ups.com mailto:flexcoders% 40yahoogroups. com mailto:flexcoders%40yahoogroups.com , Angelo Anolin angelo_anolin@ ... wrote: Hi Amy, But as you can see in the function, I am specifying the Datafieldname from the object which was passed. How can I make it more generic so that I can re-use it in other datagrid columns? I hope you could provide some samples. thanks. Angelo _ _ __ From: Amy amyblankenship@ ... To: flexcod...@yahoogro ups.com mailto:flexcoders% 40yahoogroups. com mailto:flexcoders%40yahoogroups.com Sent: Fri, 19 March, 2010 9:13:38 Subject: [flexcoders] Re: Reuse a LabelFunction  --- In flexcod...@yahoogro ups.com, Angelo Anolin angelo_anolin@ ... wrote: Hi FlexCoders, I have created a labelfunction which I use in my datagrid to format the display value. mx:DateFormatter id=df formatString= DD/MM/ / And this is the AS function private function labelFunctionTest( itm:Object, col:DataGridColumn) :String {    return df.format(itm. DataFieldNamefor Col1); } Is there a way so that I could reuse the same label function to other datagrid columns? As you can see from the script above, I am only using the function to Col1 for the datagrid. How would I be able to specify the datafield if I am going to reuse the same with other datagrid columns? That is what the DataGridColumn parameter is for. Look at its dataField property. HTH; Amy -- Alex Harui Flex SDK Team Adobe System, Inc. http://blogs.adobe.com/aharui
Re: [flexcoders] Re: Reuse a LabelFunction
Should be df.format(item[col.dataField]) On 3/17/10 1:41 PM, valdhor valdhorli...@embarqmail.com wrote: Use an itemRenderer instead. If you need help creating one, let me know. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Angelo Anolin angelo_ano...@... wrote: Hi FlexCoders, I have created a labelfunction which I use in my datagrid to format the display value. mx:DateFormatter id=df formatString=DD/MM/ / And this is the AS function private function labelFunctionTest(itm:Object, col:DataGridColumn) :String { return df.format(itm.DataFieldNameforCol1); } Is there a way so that I could reuse the same label function to other datagrid columns? As you can see from the script above, I am only using the function to Col1 for the datagrid. How would I be able to specify the datafield if I am going to reuse the same with other datagrid columns? Thanks. -- Alex Harui Flex SDK Team Adobe System, Inc. http://blogs.adobe.com/aharui
Re: [flexcoders] Re: Reuse a LabelFunction
Ho would I be able to specify other dataField based from your example? Say in my datagrid, col1's datafield is COL1 and col2 is COL2. Using the label function, I need to fully qualify the datafield name like: df.format(item[col.COL1]) which in turn I could only use for COL1. Since I have some datagrid where the same date formatting can be used, then perhaps re-using the same label function would be of good help. Thanks. From: Alex Harui aha...@adobe.com To: flexcoders@yahoogroups.com flexcoders@yahoogroups.com Sent: Wed, 17 March, 2010 19:13:26 Subject: Re: [flexcoders] Re: Reuse a LabelFunction Should be df.format(item[ col.dataField] ) On 3/17/10 1:41 PM, valdhor valdhorlists@ embarqmail. com wrote: Use an itemRenderer instead. If you need help creating one, let me know. --- In flexcod...@yahoogro ups.com mailto:flexcoders% 40yahoogroups. com , Angelo Anolin angelo_anolin@ ... wrote: Hi FlexCoders, I have created a labelfunction which I use in my datagrid to format the display value. mx:DateFormatter id=df formatString=DD/MM/ / And this is the AS function private function labelFunctionTest( itm:Object, col:DataGridColumn) :String { return df.format(itm. DataFieldNamefor Col1); } Is there a way so that I could reuse the same label function to other datagrid columns? As you can see from the script above, I am only using the function to Col1 for the datagrid. How would I be able to specify the datafield if I am going to reuse the same with other datagrid columns? Thanks. -- Alex Harui Flex SDK Team Adobe System, Inc. http://blogs. adobe.com/ aharui
Re: [flexcoders] Re: Reuse a LabelFunction
I do know a bit of using itemrenderer.. Inline that is.. if you could post some example, I'd greatly appreciate it. would the itemrenderer be an as file or would it be inline as well? Thanks. Angelo From: valdhor valdhorli...@embarqmail.com To: flexcoders@yahoogroups.com Sent: Wed, 17 March, 2010 14:41:19 Subject: [flexcoders] Re: Reuse a LabelFunction Use an itemRenderer instead. If you need help creating one, let me know. --- In flexcod...@yahoogro ups.com, Angelo Anolin angelo_anolin@ ... wrote: Hi FlexCoders, I have created a labelfunction which I use in my datagrid to format the display value. mx:DateFormatter id=df formatString= DD/MM/ / And this is the AS function private function labelFunctionTest( itm:Object, col:DataGridColumn) :String { return df.format(itm. DataFieldNamefor Col1); } Is there a way so that I could reuse the same label function to other datagrid columns? As you can see from the script above, I am only using the function to Col1 for the datagrid. How would I be able to specify the datafield if I am going to reuse the same with other datagrid columns? Thanks.