You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Paul Hardiman <co...@hardiman.com> on 2017/02/16 12:45:28 UTC

Spark GridItemRenderer not rendering

Hi,
I have a situation involving a Spark DataGrid using a custom Spark GridItemRenderer.
It’s all in ActionScript use Spark components.

The invocation:
			colL = new GridColumn();
			colL.headerText = "Calorie";
			colL.dataField = "calorie";
			renderL = new ClassFactory(PrecisionFormater);
			colL.itemRenderer = renderL;
			propL = new Object();
			propL.fldName = "calorie";
			propL.precision = 3;
			renderL.properties = propL;
			colsL.addItem(colL);


The GridItemRenderer
	public class PrecisionFormater extends GridItemRenderer
	{
		public var fldName:String;
		public var precision:uint;

		override public function set data(valueA:Object):void
		{
			if(null == valueA)
				return;
			var labelL:Label = new Label();
			var numL:Number = Number(valueA[fldName]);
			var bufL:String = String(numL.toFixed(precision));
			super.data = bufL;
			labelL.text = bufL;
			super.labelDisplay = labelL;
		}
When I step through the code, bufL looks like I would expect. However, the grid renders blanks in the column.
I just recently added the Label, but no joy.

Appreciate any assist.

Ciao
P. Hardiman


Re: Spark GridItemRenderer not rendering

Posted by Kyle McKnight <ka...@gmail.com>.
Awesome! Glad it worked!

Kyle


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Thu, Feb 16, 2017 at 8:51 AM, Paul Hardiman <co...@hardiman.com> wrote:

> You guys rock!
>
> Here is the new and WORKING GridItemRenderer with the Label object
> formally added:
>
> public class PrecisionFormater extends GridItemRenderer
> {
>         public var fldName:String;
>         public var precision:uint;
>
>         private var labelM:Label = new Label();
>
>         override public function set data(valueA:Object):void
>         {
>                 if(null == valueA)
>                         return;
>                 var numL:Number = Number(valueA[fldName]);
>                 var bufL:String = String(numL.toFixed(precision));
>                 labelM.text = bufL;
>         }
>
>         override protected function createChildren():void
>         {
>                 super.createChildren();
>                 super.addElement(labelM);
>         }
>
>         public function PrecisionFormater()
>         {
>                 super();
>         }
> }
>
> Very happy with the results.
>
> Ciao
> P. Hardiman
>
> > On Feb 16, 2017, at 8:15 AM, Kyle McKnight <ka...@gmail.com> wrote:
> >
> > I believe you should technically override createChildren of UIComponent
> and
> > create any children in there.
> >
> > http://help.adobe.com/en_US/FlashPlatform/reference/
> actionscript/3/mx/core/UIComponent.html#createChildren()
> >
> >
> > Kyle McKnight
> > Senior UI Engineer - Accesso
> > 602.515.1444 (M)
> >
> > On Thu, Feb 16, 2017 at 8:03 AM, OK <po...@olafkrueger.net> wrote:
> >
> >>
> >>> I just recently added the Label, but no joy.
> >> You probably have to add your label to the display list by using:
> >>
> >> this.addElement(labelL);
> >>
> >> Maybe you should do the creation of elements rather in the constructor
> of
> >> the ItemRenderer instead of doing this in the setData() method.
> >>
> >> HTH,
> >> Olaf
> >>
> >>
> >>
> >> --
> >> View this message in context: http://apache-flex-users.
> >> 2333346.n4.nabble.com/Spark-GridItemRenderer-not-
> >> rendering-tp14689p14690.html
> >> Sent from the Apache Flex Users mailing list archive at Nabble.com.
> >>
>
>

Re: Spark GridItemRenderer not rendering

Posted by Paul Hardiman <co...@hardiman.com>.
You guys rock!

Here is the new and WORKING GridItemRenderer with the Label object formally added:

public class PrecisionFormater extends GridItemRenderer
{
	public var fldName:String;
	public var precision:uint;

	private var labelM:Label = new Label();

	override public function set data(valueA:Object):void
	{
		if(null == valueA)
			return;
		var numL:Number = Number(valueA[fldName]);
		var bufL:String = String(numL.toFixed(precision));
		labelM.text = bufL;
	}

	override protected function createChildren():void
	{
		super.createChildren();
		super.addElement(labelM);
	}

	public function PrecisionFormater()
	{
		super();
	}
}

Very happy with the results.

Ciao
P. Hardiman

> On Feb 16, 2017, at 8:15 AM, Kyle McKnight <ka...@gmail.com> wrote:
> 
> I believe you should technically override createChildren of UIComponent and
> create any children in there.
> 
> http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/UIComponent.html#createChildren()
> 
> 
> Kyle McKnight
> Senior UI Engineer - Accesso
> 602.515.1444 (M)
> 
> On Thu, Feb 16, 2017 at 8:03 AM, OK <po...@olafkrueger.net> wrote:
> 
>> 
>>> I just recently added the Label, but no joy.
>> You probably have to add your label to the display list by using:
>> 
>> this.addElement(labelL);
>> 
>> Maybe you should do the creation of elements rather in the constructor of
>> the ItemRenderer instead of doing this in the setData() method.
>> 
>> HTH,
>> Olaf
>> 
>> 
>> 
>> --
>> View this message in context: http://apache-flex-users.
>> 2333346.n4.nabble.com/Spark-GridItemRenderer-not-
>> rendering-tp14689p14690.html
>> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>> 


Re: Spark GridItemRenderer not rendering

Posted by Kyle McKnight <ka...@gmail.com>.
I believe you should technically override createChildren of UIComponent and
create any children in there.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/UIComponent.html#createChildren()


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Thu, Feb 16, 2017 at 8:03 AM, OK <po...@olafkrueger.net> wrote:

>
> >I just recently added the Label, but no joy.
> You probably have to add your label to the display list by using:
>
> this.addElement(labelL);
>
> Maybe you should do the creation of elements rather in the constructor of
> the ItemRenderer instead of doing this in the setData() method.
>
> HTH,
> Olaf
>
>
>
> --
> View this message in context: http://apache-flex-users.
> 2333346.n4.nabble.com/Spark-GridItemRenderer-not-
> rendering-tp14689p14690.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Re: Spark GridItemRenderer not rendering

Posted by OK <po...@olafkrueger.net>.
>I just recently added the Label, but no joy.
You probably have to add your label to the display list by using:

this.addElement(labelL);

Maybe you should do the creation of elements rather in the constructor of
the ItemRenderer instead of doing this in the setData() method.

HTH,
Olaf



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Spark-GridItemRenderer-not-rendering-tp14689p14690.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.