Center text in Datagrid columns

Hi all,
I need help vertically centering text in a datagrid column.
Does anyone know of a way to do this without custom item
Renderers?

Would really need to see the code to see the extent of the damage Photoshop html has caused. This is a typical problem when exporting html from Photoshop OR trying to assemble the slices into one gigantic table where the cells have been split and merged numerous times which causes distortion.
The idea, looking at your page, would be to insert a simple 3 column x 1 row table into Dreamweaver then insert the components that make up your page into their realtive columns. Using this simple construction method will ensure that all the page elements remain seperate and cannot interact with other element in different cells, which is what is NOT happening in your construction at the moment. 

Similar Messages

  • Center text in table column expanding and distorting side columns

    Anyone out there that can help me with this, I would appreciate it. I've created the table for this web page in photoshop and sliced it up. The center column is were the body of the text is displayed as you can see from the screen shot. The body text on some of the pages extends below the design of the page. This is dependent on how much content I have of course. If the text continues below the table parameters, the outer cells stretch out, causing separation of the sliced images in the side columns, as you can see in the other screen shot. This only happens in I.E. of course. In safari the table has no problems.
    Is there any way to get this under control in I.E? I have tried everything that I can think of. I have battled with this for far too long now.
    Any Help would really be appreciated
    Thanks,
    Duncan

    Would really need to see the code to see the extent of the damage Photoshop html has caused. This is a typical problem when exporting html from Photoshop OR trying to assemble the slices into one gigantic table where the cells have been split and merged numerous times which causes distortion.
    The idea, looking at your page, would be to insert a simple 3 column x 1 row table into Dreamweaver then insert the components that make up your page into their realtive columns. Using this simple construction method will ensure that all the page elements remain seperate and cannot interact with other element in different cells, which is what is NOT happening in your construction at the moment. 

  • Datagrid column text styles

    I have a datagrid column that contains strings in this
    syntax: ##% (##%)
    When the percentages are over 0% I'd like the text to be
    green; when the percentages are under 0%, I'd like to change the
    text to red. Apart from breaking this into two columns, how can I
    change the colors of different strings inside the same datagrid
    column?
    Thanks,
    Tom

    Tom,
    One way to do this would be to make a custom ItemRenderer
    based on a Label for your dataGrid column. Then, just test whether
    you have positive or negative values for your dataField. If it is
    negative, use a setStyle('color', 0xFF0000) for red. Here is a
    basic example:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Label xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
    override public function set data(value:Object):void {
    super.data = value;
    if (value != null)
    if(value.fieldValue >= 0) //fieldValue will need to match
    your dataField value from your dataProvider of your dataGrid. You
    might need to convert it to an int to compare.
    setStyle("color", 0x00DD00);
    } else {
    setStyle("color", 0xDD0000);
    super.invalidateDisplayList();
    ]]>
    </mx:Script>
    </mx:Label>
    Then in your main app:
    <mx:DataGridColumn headerText="Drill Type"
    dataField="fieldVAlue" width="105"
    itemRenderer="renderers.RedGreen"/>
    This assumes that your mxml component is named
    'RedGreen.mxml' and is in the 'renderers' directory. You can adjust
    this to fit your project as needed. I hope this helps.
    Vygo

  • Dynamic text in a dataGrid column?

    i have a datagrid. i want to populate the first column with a different label depending on the row number.
    A good example of this would be
    Column 1 label
    Label 1
    Label 2
    Label 3
    Label 4
    I have these labels in an array, so i could access them if i had the row number.
    Anyone know how to do this?
    thanks!

    Hi peteandrus,
    You can simply use the code snippet below to display the labels row wise....
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
       <mx:Script>
       <![CDATA[
        import mx.controls.Alert;
          [Bindable]private var myAC:Array = [
             {Column1:'Label 1', Column2:"Text 1"},
             {Column1:'Label 2', Column2:"Text 2"},
             {Column1:'Label 3', Column2:"Text 3"},
             {Column1:'Label 4', Column2:"Text 4"}
       ]]>
       </mx:Script>
    <mx:DataGrid id="dataGrid" dataProvider="{myAC}" x="10" y="177" visible="true">          
      <mx:columns>
       <mx:DataGridColumn  headerText="Column 1 label" dataField="Column1"/>           
       <mx:DataGridColumn dataField="Column2" headerText="Column 2 label" />           
      </mx:columns>
    </mx:DataGrid>
    </mx:Application>
    If you really want to find the row index based assignment you can try something using labelFunction for the DataGrid column...
    Something like below:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
       <mx:Script>
       <![CDATA[
        import mx.controls.dataGridClasses.DataGridColumn;
        import mx.controls.Alert;
        [Bindable]private var myAC:Array = [
      {Column1:'Label 1', Column2:"Text 1"},
            {Column1:'Label 2', Column2:"Text 2"},
            {Column1:'Label 3', Column2:"Text 3"},
            {Column1:'Label 4', Column2:"Text 4"}
    private var counter:int=-1;         
        private function column1LabelFunction(item:Object, coulmn:DataGridColumn):String
         var strLabel:String="";
         counter++;
         if(counter < myAC.length)
          strLabel = myAC[counter].Column1;
      return strLabel;    
       ]]>
       </mx:Script>
    <mx:DataGrid id="dataGrid" dataProvider="{myAC}" x="10" y="177" visible="true">          
      <mx:columns>
       <mx:DataGridColumn  headerText="Column 1 label" labelFunction="column1LabelFunction"/>           
       <mx:DataGridColumn dataField="Column2" headerText="Column 2 label" />           
      </mx:columns>
    </mx:DataGrid>
    </mx:Application>
    Thanks,
    Bhasker Chari

  • If myText.text == any value in a datagrid column

    Hey guys, in a simple form, I am trying to achieve what's in my title.
    I have a text box in which you type in a value (number).
    I have a submit button which inserts the value into my data-grid which  is populated by a data provider to display that information (ZendAMF).
    For my submit button function I need it to loop through all the  values(rows) in a column (my dataprovider) of my data-grid to check if my text box value  is equal to any of the data in the rows for that column.
    I found a function on another forum that should help me achieve this but I still cannot get it to work as I don't think I'm using the function correctly. Note the function is called "findItem()"
    Here is my example code:
    //I have a datagrid
    <mx:DataGrid id="myDataGrid"  dataProvider="amfcall.getData.lastResult}">
             <mx:columns>
                <mx:DataGridColumn  headerText="MyHeading" dataField="myDataField"/>
             </mx:columns>
    </mx:DataGrid>
    //I  have a form for adding data into the datagrid
    <mx:Form  id="addData">
        <mx:FormItem>
            <mx:TextInput  id="myText"/>
        </mx:FormItem>
    </mx:Form>
    //I  have a button to submit the form data by calling a function
    <mx:Button  label="Add" id="addData" click="findItem()"/>
    //I  have the function to find any item in the datagrid column that is equal  to the text input in the form. This is what I can't code correctly.
    public  function findItem(myDataGrid.dataProvider, myDataField:String,  myText.text):Boolean
         for each(var item:Object in  myDataGrid.dataProvider)    
              if(item[myDataField] == myText.text)            
                return  true;    
         return false;
    So I don't think I'm correctly typing the first line of the 'findItem' function as I'm currently receiving [I]1084: Syntax error: expecting rightparen before dot.[/I] for this line [I]public function findItem(myDataGrid.dataProvider, myDataField:String, myText.text):Boolean [/I]
    Also, the error does not change if I strict type those things to ':Object' etc.
    I may just be using the function totally wrong, can anyone hlpe me out?

    Hard to tell what’s going on from the information you are providing; but just looking at the first line of your sample code:
    Have you checked in the debugger to see what your dataProvider looks like?
    You want a resultHandler to set some kind of list – let’s say a previously declared AC, which then becomes your dataProvider for the DataGrid. Something like:
    private function amfCallResultHandler(event:ResultEvent):void{
          Var someVar:ArrayCollection = event.result as ArrayCollection;
          blah blah blah;
          myDataProvider = someVar;    
    HTH,
    Carlos

  • Changing a datagrid column image according to the datagrid column value

    Flash Builder 4.5 / SDK 4.5.1.
    Fairly new to Flash Builder & Flex
    Application targets tablets so it's a "mobile" project.
    Been beating my head up against the wall on trying to figure out how to do this. Watched videos on Lynda.com.  Read Adobe "docs" till my eyes glaze over.  Takes me about 2 lines of code in my corresponding .NET project doing the same thing.....
    Tried numerous examples.  Inline rendering, external rendering files per the examples.
    I have a response field in the database and corresponding column in the s:datagrid.  If the "reportInfoResponse" field is null (not answered), show an image with a question mark.  If yes show an image with "Yes" on it.  Same for a no answer.
    I get errors of:
    1120:Access of undefined property negativeAnswer.
    1120:Access of undefined property affirmativeAnswer
    1120:Access of undefined property reportInfoResponse
    1120:Access of undefined property showResponseImage
    If I put this in an external rendering file I also get an error where it can't access the datafield (reportInfoResponse).  I've tried data.reportInfoResponse, {data.reportInfoResponse}, {reportInfoResponse} and just plain reportInfoResponse the external rendering file with no luck.  I've tried single and double quotes around Y and N.  According to all the examples (not to say there aren't more!), I should be able to reference data.reportInfoResponse in the external file and things should be fine.  Of course, the examples are bare bones code and I don't have a clue if any importing of classes or other items need to take place.  I never see any references of such.  The examples also show the image embedding and changing the image by using imageID.source=...  In my code it tells me it can't find it.
    I have put (ERROR HERE...) on the lines where I'm getting the error messages.  I've eliminated a lot of database scripting and such cause that's all working. 
    Any and all suggestions would be appreciated as I'm pulling out what little hair I have left.......and that's not much at my age........  And yes, I probably could do it by just show text in the column, but that's not what the customer wants... There are other columns I need to do this for so I figure if I can get 1 done and working, the rest are a snap.  I CAN use inline or external rendering to show an image.  It's the changing it that is the catch.........
    Thanks in advance!
    <?xml version="1.0" encoding="utf-8"?>
    <s:View 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="onCreationComplete()"
    title="{whichCategoryName} > {whichSubCatName} > Questions">
    <fx:Script>
    <![CDATA[
    import com.adobe.serializers.utility.TypeUtility;
    import flash.data.SQLConnection;
    import flash.data.SQLMode;
    import flash.data.SQLResult;
    import flash.events.StatusEvent;
    import flash.filesystem.File;
    import flash.net.URLRequest;
    import flash.net.URLVariables;
    import flash.net.navigateToURL;
    import flashx.textLayout.tlf_internal;
    import mx.collections.ArrayCollection;
    import mx.core.BitmapAsset;
    import mx.events.FlexEvent;
    import spark.events.GridEvent;
    import spark.events.IndexChangeEvent;
    ...(lots of database coding left out here)
    <s:DataGrid id="showQuestions" width="100%" height="100%"
    creationComplete="Grid_creationCompleteHandler(event)" fontFamily="_sans"
    gridClick="gridClickEvent(event);" horizontalScrollPolicy="off"
    selectionColor="#8AD8EF" selectionMode="singleRow" sortableColumns="false"
    variableRowHeight="true" verticalCenter="middle">
    <s:columns>
    <s:ArrayList>
    <s:GridColumn visible="false" dataField="id_report" headerText="id_report" resizable="true" sortable="false"></s:GridColumn>
    <s:GridColumn visible="false" dataField="id_question" headerText="id_question" resizable="true" sortable="false"></s:GridColumn>
    <s:GridColumn id="col_reponse" visible="true" dataField="reportInfoResponse" headerText="Response" resizable="true" sortable="false">
    <s:itemRenderer>
    <fx:Component>
    <s:GridItemRenderer>
    <fx:Script>
    <![CDATA[
    [Embed(source="assets/unknown.png")]
    [Bindable]
    public var unknownAnswer:Class;
    [Embed(source="assets/yes.png")]
    [Bindable]
    public var affirmativeAnswer:Class;
    [Embed(source="assets/no.png")]
    [Bindable]
    public var negativeAnswer:Class;
    (ERROR HERE - 1120:Access of undefined property reportInfoResponse)
    if(reportInfoResponse == "Y")
    (ERROR HERE - 1120:Access of undefined property showResponseImage)
    showResponseImage.source = affirmativeAnswer;
    (ERROR HERE - 1120:Access of undefined property reportInfoResponse)
    if (reportInfoResponse == "N")
    (ERROR HERE - 1120:Access of undefined property showResponseImage)
    showResponseImage.source = negativeAnswer;
    ]]>
    </fx:Script>
    <s:Image id="showResponseImage" source="{unknownAnswer}" verticalCenter="0" horizontalCenter="0"/>
    </s:GridItemRenderer>
    </fx:Component>
    </s:itemRenderer>
    </s:GridColumn>
    <s:GridColumn id="col_question" visible="true" dataField="question" headerText="Question" resizable="true" sortable="false"></s:GridColumn>
    </s:ArrayList>
    </s:columns>
    <s:AsyncListView list="{showTheseQuestions}"/>
    </s:DataGrid>
    </s:View>

    Ioan Thanks for the reply.
    Probably my previous explanation of the problem was a little incomplete. Let me give a better description.
    The situation is something like this.
    I have a requirement in which the customer wants the column header to reflect the 'keep filter value' restriction that he does dynamically in the query report.
    i.e:
    -- usually the kf column header shows 'sales volume'
    -- column header with text variable of the Calender year / month variable -- 'sales volume for 2000 oct'
    -- but when the report is run, if the user wants to go and change the filter:   calender year / month > rt clk > keep filer value > select Jan 2003.
      The kf column header still shows 'Sales Volume 2000 Oct'
    How to make the column header change to 'sales volume for Jan  2003' ?
    Any suggestions greatly appreciated.
    Thanks,

  • How to center text in Pages to show correctly on iBook Reader

    Hi,
    First, I have to say that I posted the same question on ''Creating ePubs'' discussioun page but nobody could help.
    I am trying something really easy but could not solve it. Hope someone can help.
    Ok, I know that if I choose ''Chapte Name'' as a pharagraph style, iBook reader automatically puts it into a new page, so the new page starts with the chapter name on top. I dont have any problems with my chapters.
    However, I want my book to start with a page that has a brief info about the author. I want this info in the middle of the page (also centered in the middle). Than I want to go to the second page with a ''dedication'' part where I write my thanks to people. I also want this in the middle and centered. And finally I want to add my book title and author name together on the 3rd page. After that the chapters will start.
    So, as I told you, the chapters work just fine. But when I try to center the text in the first 3 pages, (I press return several times on my keybord to do it) the pages interwine with each other. For example, the last part of page 2 goes on top of page 3.
    I think this happens because I press the return key to center the texts. So, is there a way to lock texts to the pages where they belong to prevent them to interwine with other pages even if I press return to center the text
    OR
    Is there another way to center text to prevent them to interwine with other pages...
    Thank you

    One of the consequences of working all night on this was that there is errata, or improved insight.
    As I mentioned previously, each of the four document parts that I tested is in its own section. This means that each of the first three document icons, in thumbnail view, has its own distinct yellow race track around it. The chapter/body text is in a fourth multi-page section.
    On the first page, with invisibles and layout mode shown, I have a ¶ (pilcrow) showing on line 1, column 1. If I place the cursor before this mark, the text inspector shows the following:
    Style is body
    Character spacing is 0%
    Line spacing is single (1)
    Before paragraph is set to 172 pt.
    After paragraph is set to 6 pt.
    Now, if I place the cursor before the About the Author string:
    Ruler set to 1.6 inches
    Style is Heading 1
    Character spacing is 0%
    Line Spscing is single (1)
    Before paragraph is set to 196 pt
    After paragraph is set to 6 pt
    Place cursor between end of Author and Pilcrow and press return.
    With the cursor before the author description:
    Style is body
    My font choice was Baskerville, Regular 12 pt.
    Left ruler set to 1.6 inches. Right ruler to 6.2 inches.
    Character spacing is -4%
    Line-height is set at multiple (1.2)
    Before paragraph is 0
    After paragraph is 12 pt.
    Position cursor between last character and pilcrow - press return.
    Insert section break
    This is all there is too my first page:
    For the Dedication page:
    Line 1, Col 1 has the pilcrow and style is body
    Character spacing is 0%
    Line height is single (1)
    Before and After paragraph are set to 0
    With the cursor just before Dedication:
    Left ruler set at 2.6 inches
    Style is Heading 1
    Character spacing is 0
    Line height is 1.5
    Before paragraph set to 190 pt
    After paragraph set to 0 (yeah, raised my eyebrow too)
    Place cursor between trailing n and pilcrow, press return.
    With cursor on first line of names, just prior to first character:
    Style is body text with Baskerville Regular 12 pt override.
    Text justification is left.
    Left ruler is set to 2.9 inches
    Right ruler is set to 6.7 inches
    Character spacing is 0
    Line-height is 1.2
    Before and after paragraph are 0
    Insert cursor before last Pilcrow and press return
    On the next line, there is a Pilcrow at col 1, place the cursor in front of it.
    Style is body style
    Character spacing is 0
    Line-height is multiple (1.2)
    Before paragraph is 0
    After paragraph is 216 pt.
    Press return to set the jump.
    Insert section break
    You can likely insert step 14 at step 7 and skip 9 - 13. It was late.
    The Dedication page looks like this:
    Hopefully, you missed something, or it wasn't sufficiently explained previously. I hope you can duplicate the above and discover unique, centered content in your ePub.

  • Vertically center text in a textbox

    Like Indesign, a way to vertically justify or center a text in a textbox.

    I don't know if there is a way to automatically center the text, but you can play with padding, if font size and height are fixed:
    .text-box *.viewport {
        -fx-padding: 15 5 3 5;
    // Tested with:
    TextBox
        text: "Hello World"
        columns: 12
        selectOnFocus: true
        layoutInfo: LayoutInfo { height: 50 }
    }

  • Dynamic DataGrid columns

    How can I get this example to wok with <mx:HTTPService>
    insead of the inline <mx:XML> ?
    Dynamic DataGrid columns
    Example of how to dynamically create DataGridColumns
    A completely dynamic DataGrid example.
    This example uses the xml from the Flexstore example. It
    examines the first product node and uses that to create the
    definitions for the columns. There is some example logic to change
    the columns properties.
    It then instantiates the GataGrid and its columns array,
    assigns the properties, and then the dataProvider, and then adds
    the dataGrid to the application container.
    The example is fully self-contained, since a portion of the
    catalog.xml file is included in the mxml.
    <?xml version="1.0" encoding="utf-8"?>
    <!-- This example uses the dataProvider to build the
    dataGrid columns dynamically -->
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical"
    creationComplete="initApp()">
    <mx:Script><![CDATA[
    import mx.controls.dataGridClasses.DataGridColumn;
    import mx.controls.DataGrid;
    import mx.collections.XMLListCollection;
    import mx.controls.Alert;
    [Bindable]
    private var _xlcCatalog:XMLListCollection; //the
    dataProvider for the DG
    //run by creationComplete
    public function initApp():void
    _xlcCatalog = new XMLListCollection(xmlCatalog.product);
    //wrap the XML product nodes in an XMLListCollection
    buildDG(); //creates the dataGrid
    }//initApp
    private function buildDG():void
    var aColumnDef:Array = getColumnDefArray(); //returns a
    noraml array of objects that specify DtaGridColumn properties
    var oColumnDef:Object;
    var dg:DataGrid = new DataGrid; //instantiate a new DataGrid
    var dgc:DataGridColumn;
    var aColumnsNew:Array = dg.columns
    var iTotalDGWidth:int = 0;
    for (var i:int=0;i<aColumnDef.length;i++) { //loop over
    the column definition array
    oColumnDef = aColumnDef
    dgc = new DataGridColumn(); //instantiate a new
    DataGridColumn
    dgc.dataField = oColumnDef.dataField; //start setting the
    properties from the column def array
    dgc.width = oColumnDef.width;
    iTotalDGWidth += dgc.width; //add up the column widths
    dgc.editable = oColumnDef.editable;
    dgc.sortable = oColumnDef.sortable
    dgc.visible = oColumnDef.visible;
    dgc.wordWrap = oColumnDef.wordWrap;
    aColumnsNew.push(dgc) //push the new dataGridColumn onto the
    array
    dg.columns = aColumnsNew; //assign the array back to the
    dtaGrid
    dg.editable = true;
    dg.width = iTotalDGWidth;
    dg.dataProvider = _xlcCatalog; //set the dataProvider
    this.addChild(dg); //add the dataGrid to the application
    }//buildDG
    //uses the first product node to define the columns
    private function getColumnDefArray():Array
    //Alert.show("colcount:" + xmlCatalog.toXMLString());
    var aColumns:Array = new Array();
    var node0:XML = xmlCatalog.product[0]; //get the first
    "product" node
    var xlColumns:XMLList = node0.children(); //get its child
    nodes (columns) as an XMLList
    var xmlColumn:XML
    var oColumnDef:Object;
    for (var i:int=0;i<xlColumns.length();i++) { //loop over
    the xmlList
    xmlColumn = xlColumns;
    oColumnDef = new Object();
    oColumnDef.dataField = xmlColumn.localName(); //make the
    dataField be the node name
    switch (oColumnDef.dataField) { //conditional column
    property logic
    case "name":
    oColumnDef.width = 80;
    oColumnDef.sortable = false;
    oColumnDef.visible = true;
    oColumnDef.editable = false;
    oColumnDef.wordWrap = false;
    break;
    case "description":
    oColumnDef.width = 200;
    oColumnDef.sortable = false;
    oColumnDef.visible = true;
    oColumnDef.editable = false;
    oColumnDef.wordWrap = true;
    break;
    case "price":
    oColumnDef.width = 40;
    oColumnDef.sortable = true;
    oColumnDef.visible = true;
    oColumnDef.editable = true;
    oColumnDef.wordWrap = false;
    break;
    case "image":
    oColumnDef.width = 100;
    oColumnDef.sortable = false;
    oColumnDef.visible = false;
    oColumnDef.editable = false;
    oColumnDef.wordWrap = false;
    break;
    default:
    oColumnDef.width = 50;
    oColumnDef.sortable = true;
    oColumnDef.visible = true;
    oColumnDef.editable = false;
    oColumnDef.wordWrap = false;
    break;
    aColumns.push(oColumnDef);
    return aColumns; //return the array
    }//getColumnDefArray
    ]]></mx:Script>
    <mx:XML id="xmlCatalog">
    <catalog>
    <product productId="1">
    <name>Nokia 6010</name>
    <description>Easy to use without sacrificing style,
    the Nokia 6010 phone offers functional voice communication
    supported by text messaging, multimedia messaging, mobile internet,
    games and more</description>
    <price>99.99</price>
    <image>assets/pic/Nokia_6010.gif</image>
    <series>6000</series>
    <triband>false</triband>
    <camera>false</camera>
    <video>false</video>
    <highlight1>MMS</highlight1>
    <highlight2>Large color display</highlight2>
    </product>
    <product productId="2">
    <name>Nokia 3100 Blue</name>
    <description>Light up the night with a
    glow-in-the-dark cover - when it's charged with light you can
    easily find your phone in the dark. When you get a call, the Nokia
    3100 phone flashes in tune with your ringing tone. And when you
    snap on a Nokia Xpress-on™ gaming cover*, you'll get
    luminescent light effects in time to the gaming
    action.</description>
    <price>139</price>
    <image>assets/pic/Nokia_3100_blue.gif</image>
    <series>3000</series>
    <triband>true</triband>
    <camera>false</camera>
    <video>false</video>
    <highlight1>Glow-in-the-dark</highlight1>
    <highlight2>Flashing lights</highlight2>
    </product>
    <product productId="3">
    <name>Nokia 3100 Pink</name>
    <description>Light up the night with a
    glow-in-the-dark cover - when it's charged with light you can
    easily find your phone in the dark. When you get a call, the Nokia
    3100 phone flashes in tune with your ringing tone. And when you
    snap on a Nokia Xpress-on™ gaming cover*, you'll get
    luminescent light effects in time to the gaming
    action.</description>
    <price>139</price>
    <image>assets/pic/Nokia_3100_pink.gif</image>
    <series>3000</series>
    <triband>true</triband>
    <camera>false</camera>
    <video>false</video>
    <highlight1>Glow-in-the-dark</highlight1>
    <highlight2>Flashing lights</highlight2>
    </product>
    <product productId="4">
    <name>Nokia 3120</name>
    <description>Designed for both business and pleasure,
    the elegant Nokia 3120 phone offers a pleasing mix of features.
    Enclosed within its chic, compact body, you will discover the
    benefits of tri-band compatibility, a color screen, MMS, XHTML
    browsing, cheerful screensavers, and much more.</description>
    <price>159.99</price>
    <image>assets/pic/Nokia_3120.gif</image>
    <series>3000</series>
    <triband>true</triband>
    <camera>false</camera>
    <video>false</video>
    <highlight1>Multimedia messaging</highlight1>
    <highlight2>Animated screensavers</highlight2>
    </product>
    <product productId="5">
    <name>Nokia 3220</name>
    <description>The Nokia 3220 phone is a fresh new cut
    on some familiar ideas - animate your MMS messages with cute
    characters, see the music with lights that flash in time with your
    ringing tone, download wallpapers and screensavers with matching
    color schemes for the interface.</description>
    <price>159.99</price>
    <image>assets/pic/Nokia_3220.gif</image>
    <series>3000</series>
    <triband>false</triband>
    <camera>true</camera>
    <video>false</video>
    <highlight1>MIDI tones</highlight1>
    <highlight2>Cut-out covers</highlight2>
    </product>
    </catalog>
    </mx:XML>
    </mx:Application>

    It should work the same way.
    What problem are you having?
    Tracy

  • How not to sort datagrid column on double click

    Hello,
    I am currently building an application containing a datagrid for data representation. I've created a custom datagridheader in order to add a input text for filtering the columns (see code below).
    My goal is to hide the textinput, and then show it on a double click on the header. So i would like to know how to avoid the sort of this column each time i double click.?
    <?xml version="1.0" encoding="utf-8"?>
    <s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        xmlns:mx="library://ns.adobe.com/flex/mx" resize="onColumnResize(event)" clipAndEnableScrolling="true" doubleClick="managefilterField(event)">
        <fx:Declarations>
            <!--- The default value of the <code>sortIndicator</code> property.
            It must be an IFactory for an IVisualElement.       
            <p>This value is specified in a <code>fx:Declaration</code> block and can be overridden
            by a declaration with <code>id="defaultSortIndicator"</code>
            in an MXML subclass.</p>
            @langversion 3.0
            @playerversion Flash 10
            @playerversion AIR 2.0
            @productversion Flex 4.5
            -->
            <fx:Component id="defaultSortIndicator">
                <s:Path data="M 3.5 7.0 L 0.0 0.0 L 7.0 0.0 L 3.5 7.0" implements="spark.components.gridClasses.IGridVisualElement">
                    <fx:Script>
                        <![CDATA[
                            import spark.components.DataGrid;
                            import spark.components.Grid;
                             *  @private
                            public function prepareGridVisualElement(grid:Grid, rowIndex:int, columnIndex:int):void
                                const dataGrid:DataGrid = grid.dataGrid;
                                if (!dataGrid)
                                    return;
                                const color:uint = dataGrid.getStyle("symbolColor");
                                arrowFill1.color = color;
                                arrowFill2.color = color;
                        ]]>
                    </fx:Script>
                    <s:fill>
                        <s:RadialGradient rotation="90" focalPointRatio="1">   
                            <!--- @private -->
                            <s:GradientEntry id="arrowFill1" color="0" alpha="0.6" />
                            <!--- @private -->
                            <s:GradientEntry id="arrowFill2" color="0" alpha="0.8" />
                        </s:RadialGradient>
                    </s:fill>
                </s:Path>
            </fx:Component>
            <!--- Displays the renderer's label property, which is set to the column's <code>headerText</code>.
            It must be an instance of a <code>TextBase</code>, like <code>s:Label</code>.
            <p>This visual element is added to the <code>labelDisplayGroup</code> by the renderer's
            <code>prepare()</code> method.   Any size/location constraints specified by the labelDisplay
            define its location relative to the labelDisplayGroup.</p>
            <p>This value is specified with a <code>fx:Declaration</code> and can be overridden
            by a declaration with <code>id="labelDisplay"</code>
            in an MXML subclass.</p>
            @langversion 3.0
            @playerversion Flash 10
            @playerversion AIR 2.0
            @productversion Flex 4.5
            -->
            <s:Label id="labelDisplay"
                     verticalCenter="1" left="0" right="0" top="0" bottom="0"
                     textAlign="start"
                     fontWeight="bold"
                     verticalAlign="middle"
                     maxDisplayedLines="1"
                     showTruncationTip="true" />
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import net.awl.ismp.console.components.misc.FilterCriteria;
                import net.awl.ismp.console.events.ColumnFilteredEvent;
                import net.awl.ismp.console.events.ColumnResizedEvent;
                import mx.events.ResizeEvent;
                import spark.components.gridClasses.IGridVisualElement;
                import mx.core.IVisualElement;
                import spark.components.DataGrid;
                import spark.components.GridColumnHeaderGroup;
                import spark.components.gridClasses.GridColumn;
                import spark.primitives.supportClasses.GraphicElement;
                // chrome color constants and variables
                private static const DEFAULT_COLOR_VALUE:uint = 0xCC;
                private static const DEFAULT_COLOR:uint = 0xCCCCCC;
                private static const DEFAULT_SYMBOL_COLOR:uint = 0x000000;
                private static var colorTransform:ColorTransform = new ColorTransform();
                 *  @private
                private function dispatchChangeEvent(type:String):void
                    if (hasEventListener(type))
                        dispatchEvent(new Event(type));                   
                protected function onColumnResize(event:ResizeEvent):void
                    dispatchEvent(new ColumnResizedEvent(ColumnResizedEvent.COLUMNRESIZED_EVT,this.width,this.column.columnInde x));
                //  maxDisplayedLines
                private var _maxDisplayedLines:int = 1;
                [Bindable("maxDisplayedLinesChanged")]
                [Inspectable(minValue="-1")]
                 *  The value of this property is used to initialize the
                 *  <code>maxDisplayedLines</code> property of this renderer's
                 *  <code>labelDisplay</code> element.
                 *  @copy spark.components.supportClasses.TextBase#maxDisplayedLines
                 *  @default 1
                 *  @langversion 3.0
                 *  @playerversion Flash 10
                 *  @playerversion AIR 1.5
                 *  @productversion Flex 4.5
                public function get maxDisplayedLines():int
                    return _maxDisplayedLines;
                override protected function stateChanged(oldState:String, newState:String, recursive:Boolean):void
                    trace("state changed from : "+oldState+" to "+newState);
                    super.stateChanged(oldState, newState, recursive);
                 *  @private
                public function set maxDisplayedLines(value:int):void
                    if (value == _maxDisplayedLines)
                        return;
                    _maxDisplayedLines = value;
                    if (labelDisplay)
                        labelDisplay.maxDisplayedLines = value;
                    invalidateSize();
                    invalidateDisplayList();
                    dispatchChangeEvent("maxDisplayedLinesChanged");
                //  sortIndicator
                private var _sortIndicator:IFactory;
                private var sortIndicatorInstance:IVisualElement;
                [Bindable("sortIndicatorChanged")]
                 *  A visual element that's displayed when the column is sorted.
                 *  <p>The sortIndicator visual element is added to the <code>sortIndicatorGroup</code>
                 *  by this renderer's <code>prepare()</code> method.  Any size/location constraints
                 *  specified by the sortIndicator define its location relative to the sortIndicatorGroup.</p>
                 *  @default null
                 *  @langversion 3.0
                 *  @playerversion Flash 10
                 *  @playerversion AIR 1.5
                 *  @productversion Flex 4.5
                public function get sortIndicator():IFactory
                    return (_sortIndicator) ? _sortIndicator : defaultSortIndicator;
                 *  @private
                public function set sortIndicator(value:IFactory):void
                    trace("setSortIndicator");
                    if (_sortIndicator == value)
                        return;
                    _sortIndicator = value;
                    if (sortIndicatorInstance)
                        sortIndicatorGroup.includeInLayout = false;
                        sortIndicatorGroup.removeElement(sortIndicatorInstance);
                        sortIndicatorInstance = null;
                    invalidateDisplayList();
                    dispatchChangeEvent("sortIndicatorChanged");
                 *  @private
                 *  Create and add the sortIndicator to the sortIndicatorGroup and the
                 *  labelDisplay into the labelDisplayGroup.
                override public function prepare(hasBeenRecycled:Boolean):void
                    trace("prepare !!");
                    super.prepare(hasBeenRecycled);
                    if (labelDisplay && labelDisplayGroup && (labelDisplay.parent != labelDisplayGroup))
                        labelDisplayGroup.removeAllElements();
                        labelDisplayGroup.addElement(labelDisplay);
                    trace(sortIndicator);
                    trace("sortIndicatorInstance : "+sortIndicatorInstance);
                    const column:GridColumn = this.column;
                    if (sortIndicator && column && column.grid && column.grid.dataGrid && column.grid.dataGrid.columnHeaderGroup)
                        const dataGrid:DataGrid = column.grid.dataGrid;
                        const columnHeaderGroup:GridColumnHeaderGroup = dataGrid.columnHeaderGroup;
                        if (columnHeaderGroup.isSortIndicatorVisible(column.columnIndex))
                            if (!sortIndicatorInstance)
                                sortIndicatorInstance = sortIndicator.newInstance();
                                sortIndicatorGroup.addElement(sortIndicatorInstance);
                                chromeColorChanged = true;
                                invalidateDisplayList();
                            // Initialize sortIndicator
                            sortIndicatorInstance.visible = true;
                            const gridVisualElement:IGridVisualElement = sortIndicatorInstance as IGridVisualElement;
                            if (gridVisualElement)
                                gridVisualElement.prepareGridVisualElement(column.grid, -1, column.columnIndex);
                            sortIndicatorGroup.includeInLayout = true;
                            sortIndicatorGroup.scaleY = (column.sortDescending) ? 1 : -1;
                        else
                            if (sortIndicatorInstance)
                                sortIndicatorGroup.removeElement(sortIndicatorInstance);
                                sortIndicatorGroup.includeInLayout = false;
                                sortIndicatorInstance = null;
                private var chromeColorChanged:Boolean = false;
                private var colorized:Boolean = false;
                 *  @private
                 *  Apply chromeColor style.
                override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                    //trace("update display list");
                    // Apply chrome color
                    if (chromeColorChanged)
                        var chromeColor:uint = getStyle("chromeColor");
                        if (chromeColor != DEFAULT_COLOR || colorized)
                            colorTransform.redOffset = ((chromeColor & (0xFF << 16)) >> 16) - DEFAULT_COLOR_VALUE;
                            colorTransform.greenOffset = ((chromeColor & (0xFF << 8)) >> 8) - DEFAULT_COLOR_VALUE;
                            colorTransform.blueOffset = (chromeColor & 0xFF) - DEFAULT_COLOR_VALUE;
                            colorTransform.alphaMultiplier = alpha;
                            transform.colorTransform = colorTransform;
                            var exclusions:Array = [labelDisplay, sortIndicatorInstance];
                            // Apply inverse colorizing to exclusions
                            if (exclusions && exclusions.length > 0)
                                colorTransform.redOffset = -colorTransform.redOffset;
                                colorTransform.greenOffset = -colorTransform.greenOffset;
                                colorTransform.blueOffset = -colorTransform.blueOffset;
                                for (var i:int = 0; i < exclusions.length; i++)
                                    var exclusionObject:Object = exclusions[i];
                                    if (exclusionObject &&
                                        (exclusionObject is DisplayObject ||
                                            exclusionObject is GraphicElement))
                                        colorTransform.alphaMultiplier = exclusionObject.alpha;
                                        exclusionObject.transform.colorTransform = colorTransform;
                            colorized = true;
                        chromeColorChanged = false;
                    super.updateDisplayList(unscaledWidth, unscaledHeight);
                 *  @private
                override public function styleChanged(styleProp:String):void
                    var allStyles:Boolean = !styleProp || styleProp == "styleName";
                    super.styleChanged(styleProp);
                    if (allStyles || styleProp == "chromeColor")
                        chromeColorChanged = true;
                        invalidateDisplayList();
                protected function managefilterField(event:MouseEvent):void
                    trace("double click sortIndicator : "+this.sortIndicatorInstance);
                    this.filterInput.visible=!this.filterInput.visible;
                    this.filterInput.includeInLayout=this.filterInput.visible;
                    this.filterSpacer.visible=this.filterInput.visible;
                    this.filterSpacer.includeInLayout=this.filterInput.visible;
                    if(!this.filterInput.visible)
                        this.filterInput.text="";
                        dispatchEvent(new ColumnFilteredEvent(ColumnFilteredEvent.COLUMNFILTERED_EVT,new FilterCriteria(this.column.dataField,this.filterInput.text)));
                    this.filterInput.setStyle("borderColor",0xFF6319);
                    this.filterInput.setStyle("focusColor",0xFF6319);
                    //this.filterInput.setStyle(
                protected function onTextInputSelection(event:MouseEvent):void
                    event.stopImmediatePropagation();
                    this.filterInput.setStyle("borderColor",0xFF6319);
                    this.filterInput.setStyle("focusColor",0xFF6319);
                protected function onKeyUp(event:KeyboardEvent):void
                    if(event.charCode==Keyboard.ENTER)
                        stage.focus=null;
                protected function onFocusOut(event:FocusEvent):void
                    this.filterInput.setStyle("borderColor",0x00ff00);
                    this.filterInput.setStyle("focusColor",0x70B2EE);
                    dispatchEvent(new ColumnFilteredEvent(ColumnFilteredEvent.COLUMNFILTERED_EVT,new FilterCriteria(this.column.dataField,this.filterInput.text)));
            ]]>
        </fx:Script>
        <s:states>
            <s:State name="normal" />
            <s:State name="hovered" />
            <s:State name="down" />
        </s:states>     
        <!-- layer 1: shadow -->
        <!--- @private -->
        <s:Rect id="shadow" left="-1" right="-1" top="-1" bottom="-1" radiusX="2">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0x000000"
                                     color.down="0xFFFFFF"
                                     alpha="0.01"
                                     alpha.down="0" />
                    <s:GradientEntry color="0x000000"
                                     color.down="0xFFFFFF"
                                     alpha="0.07"
                                     alpha.down="0.5" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 2: fill -->
        <!--- @private -->
        <s:Rect id="fill" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0xFFFFFF"
                                     color.hovered="0xBBBDBD"
                                     color.down="0xAAAAAA"
                                     alpha="0.85" />
                    <s:GradientEntry color="0xD8D8D8"
                                     color.hovered="0x9FA0A1"
                                     color.down="0x929496"
                                     alpha="0.85" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 3: fill lowlight -->
        <!--- @private -->
        <s:Rect id="lowlight" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="270">
                    <s:GradientEntry color="0x000000" ratio="0.0" alpha="0.0627" />
                    <s:GradientEntry color="0x000000" ratio="0.48" alpha="0.0099" />
                    <s:GradientEntry color="0x000000" ratio="0.48001" alpha="0" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 4: fill highlight -->
        <!--- @private -->
        <s:Rect id="highlight" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.0"
                                     alpha="0.33"
                                     alpha.hovered="0.22"
                                     alpha.down="0.12"/>
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.48"
                                     alpha="0.33"
                                     alpha.hovered="0.22"
                                     alpha.down="0.12" />
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.48001"
                                     alpha="0" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect> 
        <!-- layer 5: highlight stroke (all states except down) -->
        <!--- @private -->
        <s:Rect id="highlightStroke" left="0" right="0" top="0" bottom="0" excludeFrom="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0xFFFFFF" alpha.hovered="0.22" />
                    <s:GradientEntry color="0xD8D8D8" alpha.hovered="0.22" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!-- layer 6: highlight stroke (down state only) -->
        <!--- @private -->
        <s:Rect id="hldownstroke1" left="0" right="0" top="0" bottom="0" includeIn="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0x000000" alpha="0.25" ratio="0.0" />
                    <s:GradientEntry color="0x000000" alpha="0.25" ratio="0.001" />
                    <s:GradientEntry color="0x000000" alpha="0.07" ratio="0.0011" />
                    <s:GradientEntry color="0x000000" alpha="0.07" ratio="0.965" />
                    <s:GradientEntry color="0x000000" alpha="0.00" ratio="0.9651" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!--- @private -->
        <s:Rect id="hldownstroke2" left="1" right="1" top="1" bottom="1" includeIn="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0x000000" alpha="0.09" ratio="0.0" />
                    <s:GradientEntry color="0x000000" alpha="0.00" ratio="0.0001" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!--<s:Rect id="fill" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color.normal="0xf9f9f9" color.hovered="0xfcfdfa"
                                     color.down="0xdceac2" alpha="0.85" />
                    <s:GradientEntry color.normal="0xeaeaea" color.hovered="0xdceac2"
                                     color.down="0xd2e1b5" alpha="0.85" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>-->
        <!--<s:VGroup left="7" right="7" top="5" bottom="5" gap="6" verticalAlign="middle">
            <s:TextInput width="100%" />
            <s:HGroup width="100%">
                <s:Group id="labelDisplayGroup" width="100%" />
                <s:Group id="sortIndicatorGroup" includeInLayout="false" />
            </s:HGroup>
        </s:VGroup>-->
        <s:VGroup verticalAlign="middle" left="7" top="5" right="7" bottom="5" gap="2" >
            <s:TextInput id="filterInput" width="100%" visible="false" includeInLayout="false" keyUp="onKeyUp(event)" focusOut="onFocusOut(event)" click="onTextInputSelection(event)"/>
            <s:Spacer id="filterSpacer" visible="false" includeInLayout="false" height="5" />
        <s:HGroup width="100%" height="100%" verticalAlign="middle">
            <s:Group id="labelDisplayGroup" width="100%" />
            <s:Group id="sortIndicatorGroup" includeInLayout="false" />
        </s:HGroup>
        </s:VGroup>
    </s:GridItemRenderer>

    Based on your idea, i've intercepted the click event and I use stopImmediatePropagation.
    THen i added an image to sort the column. So if the image is clicked the sort is ok.

  • ItemRenderer in a datagrid column   setStyle() does not do anything to the appearance

    I have a custom ItemRenderer in a datagrid column, however
    the setStyle() does not do anything to the appearance. when it is
    called. Any ideas?
    <mx:DataGridColumn dataField="area" width="50"
    headerText="Area">
    <mx:itemRenderer>
    <mx:Component>
    <mx:Text>
    <mx:Script>
    <![CDATA[
    override public function set data( value:Object ) : void {
    super.data = value;
    setStyle("Color",0xff0000);
    if(data.area == 'G'){
    setStyle("backgroundColor",0xff0000);
    }else{
    setStyle("backgroundColor",0xff0000);
    ]]>
    </mx:Script>
    </mx:Text>
    </mx:Component>
    </mx:itemRenderer>
    </mx:DataGridColumn>

    Your renderer code looks a little strange. This works, and
    may get you started:

  • Datagrid column header word wrap issue

    Hi All,
    I'm passing dynamic text to a datagrid column header. The word wrap is true but it's not working.
    Any ideas how to fix this issue?
    DataGridColumn headerText="{myVar.text} Total" headerWordWrap="true"
    Thanks
    Johnny

    @Johnny,
    Try to make use of the headerRenderer property and use <mx:Text /> control as a renderer so that your headerText gets wrapped..
    Thanks,
    Bhasker
    Message was edited by: BhaskerChari

  • Cancel edition in a Datagrid Column

    What i´m wishing to do is very simple, i just want to cancel an edition in a DataGrid column,
    Loosing focus of the textbox confirms the edition, i wanted to place 2 buttons above the edition text box, cancel and confirm, but it seems to be impossible...
    any idea?
    thanks in advance!!

    Yea that seems to work fine for me so in full, with editing features
    Custom Comp
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="182" height="72"  >
    <mx:Script>
    <![CDATA[
    private function handleOk():void {
    this.data.someText = textInput.text
    override public function set data(value:Object):void {
    super.data = value;
    textInput.text = data.someText
    private function cancel():void {
    textInput.text = data.someText;
    ]]>
    </mx:Script>
    <mx:TextInput id="textInput" x="10" y="10" />
    <mx:Button x="10" y="40" label="Update" click="handleOk()"/>
    <mx:Button x="85" y="40" label="Cancel" click="cancel()"/>
    </mx:Canvas>
    Application
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    [Bindable]
    private var ac:ArrayCollection = new ArrayCollection([
    {someText : 'Line 1'},
    {someText : 'Line 2'},
    {someText : 'Line 3'},
    {someText : 'Line 4'},
    {someText : 'Line 5'},
    {someText : 'Line 6'},
    {someText : 'Line 7'},
    {someText : 'Line 8'},
    {someText : 'Line 9'},
    {someText : 'Line 10'}
    ]]>
    </mx:Script>
    <mx:DataGrid x="71" y="90" dataProvider="{ac}">
    <mx:columns>
    <mx:DataGridColumn headerText="Column 1" dataField="someText" itemRenderer="Comp1" width="182"/>
    <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
    <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:Application>
    Hope this helps
    Andrew

  • Setting the editable property of a datagrid column dynamically

    Hi,
    Im trying to set the editable property and renderer is editable property for a datagrid column to false on the creation complete event of the datagrid.But It does not work.While visible property works.why doesnt the editable property work.The particular column has a renderer which is a text box.and the editable property is set to false initially.Any Suggestions or ideas on how to achieve this will be of great help.

    Eu tenho vontade de estar devidamente por dentro de tudo isso.

  • DataGrid column width is not set properly

    Hi,
            In the below example I has called the OptimizeDataGrid method on Button Click event to resize the Column according to the data. First time of the button click event it called the function whereas the Datagrid Column width alone is not set properly.whereas on second time it is working properly.
    For Eg : In the below statement the text value is coming as 55 and widthPadding is comes as 25. but the sum of these two value is not in the dg.columns[col].width.
    dg.columns[col].width = text + widthPadding;
    But the same is working on the second time of the Button click event. is any help me out to resovle this issue. Thanks in Advance.
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        width="100%" height="100%" >
        <mx:Script>
            <![CDATA[
                import mx.utils.ObjectUtil;
                import mx.collections.ArrayCollection;
                import mx.core.UITextField;
                import mx.events.AdvancedDataGridEvent;
                import mx.binding.utils.BindingUtils;
                import mx.controls.Alert;           
                import mx.controls.AdvancedDataGrid;
                import mx.controls.advancedDataGridClasses.*;
                import mx.controls.DataGrid;
                import mx.controls.dataGridClasses.*;
                [Bindable]
                private var dpFlat:ArrayCollection = new ArrayCollection([            
                  {Region:"aabbCC", Territory:"Central Californiaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                      Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, 
                  {Region:"AAbbcc", Territory:"Nevada",
                      Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}
                private function optimizeDataGrid(dg:Object,widthPadding:uint = 0,heightPadding:uint = 0):void
                    if ((!dg is DataGrid))
                        return;
                    var col:uint;
                    var colWidth:uint;
                    var tf:TextFormat;
                    var renderer:UITextField;
                    var widths:Array = new Array(dg.columnCount);
                    var height:uint = 0;
                    var dgCol:Object;
                    var text:uint = 0;
                    if (dg.columnCount > 0 && dg.dataProvider != null)
                        for (col = 0; col < dg.columnCount; ++col)
                            widths[col] = 0;
                        for each (var item:Object in dg.dataProvider)
                            for (col = 0; col < dg.columnCount; ++col)
                                renderer = new DataGridItemRenderer();
                                dg.addChild(renderer);
                                dgCol = dg.columns[col];
                                renderer.text = dgCol.itemToLabel(item);
                                widths[col] = Math.max(renderer.measuredWidth, widths[col]);
                                height = Math.max(renderer.measuredHeight, height);
                                dg.removeChild(renderer);
                        for (col = 0; col < dg.columnCount; ++col)
                            dg.addChild(renderer);
                            renderer.text = dg.columns[col].headerText;
                            widths[col] = Math.max(renderer.measuredWidth,widths[col]);
                            dg.removeChild(renderer);
                            text = widths[col];
                            dg.columns[col].width = text + widthPadding;
                        if (height != 0)
                            dg.rowHeight = height + heightPadding;
            ]]>
        </mx:Script>
        <mx:DataGrid id="myADG"
               dataProvider="{dpFlat}" rowCount="{dpFlat.length}" sortableColumns="false">       
                 <mx:columns>
                    <mx:DataGridColumn dataField="Region" />              
                    <mx:DataGridColumn dataField="Territory_Rep" headerText="Territory Rep" />
                     <mx:DataGridColumn dataField="Territory" />
                    <mx:DataGridColumn dataField="Actual" />
                    <mx:DataGridColumn dataField="Estimate" />
                </mx:columns>
       </mx:DataGrid>
       <mx:Button label="click" id="click" click="optimizeDataGrid(myADG,25,5);"/>
    </mx:Application>
    Regards
    Harikumar

    With horizontalScrollPolicy="off" (the default), it is hard to control
    column widths because the columns are sometimes overridden to make sure they
    fit on the screen.

Maybe you are looking for

  • Process Chain - Transfering Files to Application Server

    Hi guys, I have been trying to use BW Process Chain to load data from a flat file (CSV) into an InfoCube. I understand for it to work, the file has to reside on the Application Server, and not the local workstation. However, can anyone tell me exactl

  • How do I remove e-mail address that appear in the drop down menu?

    When I enter an e-mail address the system offers me choices.  For most all of my address there are duplicates.  Also showing up is e-mail address that were typed incorrectly. When I go to Mail>Window>Previous Recipients there are no duplicates. No du

  • ITunes has stopped working on Windows server 2008R2

    Tunes has stopped working on Windws server 2008R2 server..  I have new problem to run itunes.. it opens in debug mode and windows are closing by forcebly...please help to to resolve this issue

  • Camera Raw 8.5 not updated !

    Since last CC 2014 update Camera Raw is not updated to 8.5 following Adobe Staff demands and explanation i unsintall Adobe Bridge CC , Photoshop CC, Photoshop CC 2014 i uninstalled Creative Cloud Desktop, Adobe Manager ( trashed) deleted AAM pref and

  • Function Modules for indirect values

    What are the  function modules for indirect values?