Hi,

I'm having some issues controlling the width of a text item in an inline
renderer for a datagrid cell. In the itemRenderer I've got a Number element
set to be the width of the outerDocument's datagrid.width (because Text
doesn't like "100%' as a width, it only seems to accept integers). The
problem comes when I want to account for the padding in the renderer. When I
change the calculation of the number from
"outerDocument.contentDatagrid.width" to
"outerDocument.contentDatagrid.width - 20" the datagrid blows out the bottom
of the panel it's in. If you run the code below you'll see the datagrid is
correctly bound inside the browser window. But if you change line 92 to
subtract any amount from the width the datagrid blows out the bottom of the
panel.

So, the question is what's going on here? I'd like the text to wrap
dynamically as the browser window resizes but I'd also like the datagrid to
stay inside the panel. Any suggestions? Thanks in advance.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="vertical"
creationComplete="">

<mx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;

        public var contentDataGridWidth:int;

        public var content:ArrayCollection =  new ArrayCollection(
        [
            {
                headline:"FDIC Defends Handling of IndyMac Run",
                publicationDate:"07/18/2008",
                publicationSource:"American Banker",
                leadParagraph:"WASHINGTON - Federal Deposit Insurance Corp.
officials defended the agency Thursday against charges it has improperly
handled the failure of IndyMac Bancorp Inc., stirring concerns among
depositors nationwide."
            },
            {
                headline:"Currents -- The Numbers Guy: Trying to Track
Mortgage Mess",
                publicationDate:"07/18/2008",
                publicationSource:"The Wall Street Journal ",
                leadParagraph:"Which states have been hardest hit by the
mortgage crisis? It depends on who is doing the counting, and how.Colorado
and Georgia continually rank in the top 10 nationwide, according to a
well-publicized monthly ranking of the number of ..."
            },
            {
                headline:"Reeves sees Mississippi's positives; Challenges
lie ahead, but state positioned to weather them  ",
                publicationDate:"07/18/2008",
                publicationSource:"The Sun Herald ",
                leadParagraph:"GULFPORTState Treasurer Tate Reeves said
tough economic times are coming, but he believes Mississippi is in a good
position to deal those challenges because of revenue growth and job creation
over the last five years."
            },
            {
                headline:"Ga's unemployment rate unchanged",
                publicationDate:"07/18/2008",
                publicationSource:"Macon Telegraph ",
                leadParagraph:"The Georgia Department of Labor announced
Thursday that the state's seasonally adjusted unemployment rate was
unchanged at 5.7 percent from May to June, but was up 1.3 percent from 4.4
percent in June 2007."
            },
            {
                headline:"Home sales rise for 5th month in a row  ",
                publicationDate:"07/18/2008",
                publicationSource:"Naples Daily News",
                leadParagraph:"More buyers are getting back into the game.As
home prices continue to drop in the Naples area, sales are rising and
inventories are falling."
            },
            {
                headline:"OUR OPINIONS: Dunwoody's destiny: Good leadership
will be crucial in sorting out thorny issues in newly incorporated DeKalb
city  ",
                publicationDate:"07/18/2008",
                publicationSource:"The Atlanta Journal - Constitution",
                leadParagraph:"The overwhelming vote Tuesday to incorporate
DeKalb County's first new city in 71 years --- Dunwoody --- is but the first
step those citizens made toward taking control of their community's destiny.
The harder work begins now. Given the ..."
            }
        ]);

        public function init():void
        {
            contentDataGridWidth = contentDataGrid.width;
        }

        public function getContentDataGridWidth():int
        {
            return contentDataGrid.width;
        }

        public function getContentDataGridWidthPadded():int
        {
            return contentDataGrid.width - 20;
        }


    ]]>
</mx:Script>

<mx:Panel width="100%"
          height="100%"
          >
    <mx:DataGrid id="contentDataGrid"
                 dataProvider="{content}"
                 width="100%"
                 height="100%"
                 horizontalScrollPolicy="off"
                 verticalScrollPolicy="on"
                 variableRowHeight="true"
                 headerHeight="0"
                 >
        <mx:columns>
            <mx:DataGridColumn>
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:VBox horizontalScrollPolicy="off"
                                  paddingTop="10"
                                  paddingBottom="10"
                                  paddingLeft="10"
                                  paddingRight="10"
                            >

                            <mx:Number
id="contentDataGridWidth">{outerDocument.contentDataGrid.width}</mx:Number>

                            <mx:Text text="{data.headline}"
                                     fontWeight="bold"
                                     textAlign="left"
                                     width="{contentDataGridWidth}"
                                     />

                            <mx:Text id="contentItemMetaData"
                                     text="{data.publicationDate} -
{data.publicationSource}" />

                            <mx:Text id="contentItemLead"
                                     text="{data.leadParagraph}"
                                     textAlign="left"
                                     width="{contentDataGridWidth}"
                            />

                            <mx:CheckBox id="contentItemSelectedCheckBox"
                                         label="Select for publication" />
                        </mx:VBox>
                    </mx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>
        </mx:columns>
    </mx:DataGrid>
    <mx:ControlBar>
        <mx:LinkButton label="linkbutton to something" />
    </mx:ControlBar>
</mx:Panel>

</mx:Application>


-- 
Howard Fore, [EMAIL PROTECTED]
"The universe tends toward maximum irony. Don't push it." - Jeff Atwood

Reply via email to