Yes, I know that. But seems a bazooka for a simple thing. For now I have a copy of the file on my project to override the SDK with the behaviour implemented.
Harbs <harbs.li...@gmail.com> escreveu no dia terça, 7/06/2022 à(s) 22:35: > I’d just create my own ItemRenderer with the custom label behavior. > > I have MANY custom renderers in my apps. > > > On Jun 8, 2022, at 12:16 AM, Hugo Ferreira <hferreira...@gmail.com> > wrote: > > > > I use itemRenders for more visual complex things (images, text with bold, > > etc ...) > > On this case I have a generic itemRender (visual aspect) and what's > > different it's the content. > > Doing an itemRender for each ComboBox seems to much work and a simple > > formula it's something in between for a less complex code structure. > > > > But I understand what you mean, that's why I asked in the first place > > before commit. > > > > So, what's the best option to have this implemented only on my side (if > > there is this option) ? > > I would like to have this behaviour without put on the SDK and without > > using itemRenderers. > > For another word, how to have a copy of the custom getLabelFromData and > use > > this instead of the SDK ? > > > > > > Harbs <harbs.li...@gmail.com> escreveu no dia terça, 7/06/2022 à(s) > 22:04: > > > >> Hard coding it into a function which is widely used by ItemRenderers > does > >> not seem like a good idea or very PAYG. > >> > >> Id suggest creating ItemRenderers which have this behavior. > >> > >> If there’s some way to inject the behavior into existing functions that > >> would be fine too, but I can’t think off hand of a good way of doing > that. > >> > >>> On Jun 7, 2022, at 11:48 PM, Hugo Ferreira <hferreira...@gmail.com> > >> wrote: > >>> > >>> Method getLabelFromData from getLabelFromData.as > >>> > >>> I just added a new if block that seek for "[" and thread the keys. > >>> If it's OK, I can commit, otherwise I ask what's the best alternative > >>> solution to achive the same result. > >>> > >>> public function getLabelFromData(obj:Object,data:Object):String > >>> { > >>> // slightly more code, but we bail early if it's a string which > is > >>> often > >>> if (data is String) return "" + data; > >>> if(!data) return ""; > >>> if(data is ILabeledData) return (data as ILabeledData).label; > >>> > >>> if (obj is IHasLabelField && > >>> (obj as IHasLabelField).labelField && > >>> (obj as IHasLabelField).labelField.indexOf("[") > -1) > >>> { > >>> var result:String = (obj as IHasLabelField).labelField; > >>> for each (var item:String in result.split("[")) > >>> { > >>> if (item.indexOf("]") > -1) > >>> { > >>> var field:String = item.split("]")[0]; > >>> result = result.replace("[" + field + "]", > >> data[field]); > >>> } > >>> } > >>> return result; > >>> } > >>> > >>> if (obj is IHasLabelField && > >>> (obj as IHasLabelField).labelField && > >>> data[(obj as IHasLabelField).labelField] != null) > >>> { > >>> return "" + data[(obj as IHasLabelField).labelField]; > >>> } > >>> > >>> if (obj is IHasDataField && > >>> (obj as IHasDataField).dataField && > >>> data[(obj as IHasDataField).dataField] != null) > >>> { > >>> return "" + data[(obj as IHasDataField).dataField]; > >>> } > >>> > >>> var label:String = data["label"]; > >>> if(label != null){ > >>> return label; > >>> } > >>> return "" + data; > >>> > >>> } > >>> > >>> Maria Jose Esteve <mjest...@iest.com> escreveu no dia terça, 7/06/2022 > >> à(s) > >>> 21:44: > >>> > >>>> Hugo, could it be seen? Maybe a branch or a PR? > >>>> > >>>> Hiedra > >>>> > >>>> -----Mensaje original----- > >>>> De: Hugo Ferreira <hferreira...@gmail.com> > >>>> Enviado el: martes, 7 de junio de 2022 21:58 > >>>> Para: Apache Royale Development <dev@royale.apache.org> > >>>> Asunto: Proposal for labelField with expression support > >>>> > >>>> Hi, > >>>> > >>>> In Flex "world" one can use labelField and labelFunction. > >>>> Here in Royale we have only labelField (at least I didn't see so far > >>>> support for labelFunction), however I'm not a big fan of labelFunction > >>>> anyway. > >>>> > >>>> I always wanted support for something in between of labelField and > >>>> labelFunction (labelFunction with multiple fields and fixed strings) > >> and I > >>>> implement it on my side. > >>>> > >>>> Ex: > >>>> model: > >>>> public class User > >>>> { > >>>> public var Code:String; > >>>> public var Name:String; > >>>> } > >>>> > >>>> With this model, one can use Code (user code) or Name but not the > >> combined > >>>> fields. > >>>> > >>>> With a little adition I can now do something like this: > >> labelField="[Code] > >>>> - [Name]" and at runtime every field delimited by [] it's replaced for > >> his > >>>> value, allowing multiple fields and complex expressions. > >>>> > >>>> Can I commit this or there is a reason to not do so ? > >>>> > >>>> Thank you, > >>>> Hugo. > >>>> > >> > >> > >