You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by bilbosax <wa...@comcast.net> on 2021/01/08 23:35:18 UTC

A Little Help with some Simple Actionscript

I am using a Flex MobileGrid to display some real estate date in a mobile
app.  Unfortunately, if the columns contain too much information, they do
not automatically truncate the column to ellipsis "..."  As a result, I am
trying to write an ActionScript ItemRenderer to help with this and am having
no success.  I am a MXML programmer for the most part, and use actionscript
for program logic, but I am not very good with creating my own ActionScript
classes.  I will list my ActionScript ItemRenderer here.  Please let me know
if you see anything that would help me to get the ellipsis "..." that I am
hoping for.  Thanks!


package renderers {

import flashx.textLayout.formats.LineBreak;

import spark.components.itemRenderers.MobileGridTextCellRenderer;

public class mobileGridRenderer extends MobileGridTextCellRenderer{

        public function mobileGridRenderer() {

            super();
            multiline = false;
            lineBreak = LineBreak.EXPLICIT;
            truncateToFit("...");
        }
    }
}




--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/

Re: A Little Help with some Simple Actionscript

Posted by bilbosax <wa...@comcast.net>.
I know this is basic stuff for most of you, but I thought I would add it for
anybody who may have a similar problem. I got the item renderer to work by
adding the following code:

override public function set data(value:Object):void{
    super.data = value;

    width = AppVars.appWidth * .4;
    multiline = false;
    lineBreak = LineBreak.EXPLICIT;
    truncateToFit("...");
}

Apparently, it is important to wait until the "data" has changed before you
take the actions to truncate the text, but you also have to set a width for
the StyleableTextField that is the basis of the itemrenderer for the
truncateToFit method to work properly. The thing that I cannot figure out is
why I have to calculate a width the way that I have done above instead of
getting it from the MobileGrid that the itemrenderer works on. I would think
width=this.width, or width = parent.width, or width = owner.width or
something along these lines would work, but I was sadly disappointed. In
other words, I have to write a different itemrenderer for every column that
I want to truncate because I cannot get the width of the column from within
the itemrenderer.

Any thoughts on how I might effectively get the width of the column from
within the itemrenderer so that I can apply it to the width of the
StyleableTextField so that it will truncate at the appropriate place in the
string???



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/