2

i am using spark datagrid for my application. i am using one cusomrenderer (contains one link) for my spark datagrid.Text in the columns are truncated with respect to it's column size.but the link is not truncated, it is overlapped to next column ,that is not fair.i want that link column should be truncated within its column.here i have given my sample code.

<?xml version="1.0" encoding="utf-8"?>

<s:Application name="Spark_DataGrid_columns_test"
               xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="init()">
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;

            import spark.components.Grid;
            import spark.components.gridClasses.CellPosition;
            private function init():void
            {


                var link:ClassFactory = new ClassFactory(sparkLinkRenderer);
                linkColumn.itemRenderer = link;
            }



        ]]>
    </fx:Script>
    <fx:Declarations>
        <s:ArrayList id="TweetersList">
            <fx:Object drink="onetqwo three four five six seven eight" name="Dan Florio"    twitter="polyGeek polyGeek polyGeek polyGeek polyGeek" />
            <fx:Object drink="one" name="David Ortinau"     twitter="davidortinau"  />
            <fx:Object drink="one" name="Simeon Bateman"    twitter="simBateman"/>
            <fx:Object drink="one" name="Dan Florio"    twitter="polyGeek" />
            <fx:Object drink="one" name="David Ortinau"     twitter="davidortinau" />
            <fx:Object drink="one" name="Simeon Bateman"    twitter="simBateman" />
            <fx:Object drink="one" name="Dan Florio"    twitter="polyGeek" />
            <fx:Object drink="one" name="David Ortinau"     twitter="davidortinau" />
            <fx:Object drink="one" name="Simeon Bateman"    twitter="simBateman" />
            <fx:Object drink="one" name="Dan Florio"    twitter="polyGeek" />
            <fx:Object drink="one" name="David Ortinau"     twitter="davidortinau"/>
            <fx:Object drink="one" name="Simeon Bateman"    twitter="simBateman"/>
        </s:ArrayList>
    </fx:Declarations>

    <s:DataGrid id="spdg" width="500" height="250" >
        <s:columns>
            <s:ArrayList>
                <s:GridColumn width="100" id="linkColumn"  dataField="drink"/>
                <s:GridColumn width="100" dataField="name"/>
                <s:GridColumn width="100" dataField="twitter"/>
            </s:ArrayList>
        </s:columns>
    </s:DataGrid>
</s:Application>

the link custom renderer code:

<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                    xmlns:mx="library://ns.adobe.com/flex/mx"  
                    xmlns:s="library://ns.adobe.com/flex/spark"
                    width="100%"  >
    <fx:Script>
        <![CDATA[


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

            ]]>
    </fx:Script>
    <mx:LinkButton id="linkButton" color="#170909" textAlign="left" fontWeight="normal" textDecoration="underline">
    </mx:LinkButton>
</s:GridItemRenderer>

sample snapshot of my output:

enter image description here

please suggest me on this issue.

thanks in advance, vengatesh

ketan
  • 19,129
  • 42
  • 60
  • 98
vengatesh
  • 503
  • 1
  • 6
  • 15

1 Answers1

2

Well first i posted bounty and then i found a solution...

GridItemRenderer has a property clipAndEnableScrolling which does just that if set to true.

<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:mx="library://ns.adobe.com/flex/mx"  
                xmlns:s="library://ns.adobe.com/flex/spark"
                width="100%" 
                clipAndEnableScrolling="true">
<fx:Script>
    <![CDATA[


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

        ]]>
</fx:Script>
<mx:LinkButton id="linkButton" color="#170909" textAlign="left" fontWeight="normal" textDecoration="underline">
</mx:LinkButton>

Smalcat
  • 231
  • 3
  • 18
  • great!!it works. i had done by putting the linkbutton inside a hgroup which has the same property(ClipandEnableScrolling). – vengatesh May 04 '12 at 11:03