Automatic DataGrid columns

I thought I remember reading that if you left out the < mx:columns > or < mx:DataGridColumn > tags a DataGrid it would automatically create columns of the dataProvider. I searched everywhere and can not find yet... is this possible or is it a dream I had?

Thank you
M

It's true. For each column headerText property will be the name of the property in the collection ArrayCollection object.

Tags: Flex

Similar Questions

  • Resizing DataGrid column width

    How can I enable the user to quickly adjust automatically a column by double-clicking it, as you can do in Excel?

    Also, how could I have the columns automatically sized this way during load?

    No mechanism built as far as I know. This shuold help you get started:

    var int cols = this.dg.columnCount;
    for (var i: int = 0; i< cols;="" i++)="">
    Col: DataGridColumn var = dg.columns [i];

    var tlm:TextLineMetrics = dg.measureText (col.headerText);
    Col.Width = tlm.width;
    }

    Basically, you'll need to go on each column, measure the width of the text that is in this case, I will put only the width as wide as the header text - using the TextLineMetrics class and set the column width. You might alos have invalidated the DataGrid Properties after the loop to force a refresh.

    ATTA

  • How not to sort datagrid column on double click

    Hello

    I'm currently building an application containing a DataGrid for the representation of data. I created a datagridheader custom in order to add an input text for the filtering of the columns (see code below).

    My goal is to hide the textinput and then display it on a double click on the header. So I would like to know how to avoid the type of this column whenever I double click. ?

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

    " < = xmlns:fx s:GridItemRenderer ' 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 sortIndicator < code > < code > property.

    It must be an IFactory for an IVisualElement.

    < p > This value is specified in a < code > < code > fx:Declaration block and can be overridden

    by a supporting statement < code > = "defaultSortIndicator" </postcode >

    in an MXML subclass. < /p >

    @langversion 3.0

    @playerversion flash 10

    @playerversion AIR 2.0

    @productversion flex 4.5

    ->

    < fx:Component id = "defaultSortIndicator" >

    < data s:Path = "M 3.5 7.0 L 0.0 0.0 7.0 0.0 L 3.5 7.0 L" implements = "spark.components.gridClasses.IGridVisualElement" >

    < fx:Script >

    <! [CDATA]

    Import spark.components.DataGrid;

    Import spark.components.Grid;

    /**

    * @private

    */

    public void 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 label of renderer property, which is the value of the column < code > < code > headerText.

    It must be an instance of a TextBase < code > < code > < code > < code > s:Label.

    < p > This Visual element is added to the < code > < code > labelDisplayGroup by of the rendering engine

    prepare() < code > < code > method.   Constraint of size/location specified by the labelDisplay

    define its location relative to the labelDisplayGroup. < /p >

    < p > This value is not specified with a < code > < code > fx:Declaration and can be overridden

    by a supporting statement < code > = "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".

    Red left = "1" = "0" right = "0" top = low '0' = '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;

    variables and constants of color chrome

    DEFAULT_COLOR_VALUE:uint private static const is 0xCC;.

    DEFAULT_COLOR:uint private static const is 0xCCCCCC;.

    Private static const DEFAULT_SYMBOL_COLOR:uint = 0 x 000000;

    private static var colorTransform:ColorTransform = new ColorTransform();

    /**

    * @private

    */

    private void 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")]

    /**

    This property value is used to initialize the

    * < code > < code > maxDisplayedLines property of this converter

    * < code > labelDisplay < code > element.

    *

    * @copy #maxDisplayedLines spark.components.supportClasses.TextBase

    *

    * @default 1

    *

    * @langversion 3.0

    * @playerversion flash 10

    * @playerversion AIR 1.5

    * @productversion flex 4.5

    */

    public function get maxDisplayedLines (): int

    {

    Return _maxDisplayedLines;

    }

    override the stateChanged(oldState:String,_newState:String,_recursive:Boolean):void function

    {

    trace ("status changed to:" + 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 appears when the column is sorted.

    *

    * < p > the sortIndicator visual element is added to the < code > < code > sortIndicatorGroup

    * by this converter < code > < code > prepare() method.  Constraint of size/location

    * specified by the sortIndicator set 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 is 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 in the labelDisplayGroup.

    */

    override public function prepare(hasBeenRecycled:Boolean):void

    {

    trace ("ready!");

    Super.Prepare (hasBeenRecycled);

    If (labelDisplay & & labelDisplayGroup & & (labelDisplay.parent! = labelDisplayGroup))

    {

    labelDisplayGroup.removeAllElements ();

    labelDisplayGroup.addElement (labelDisplay);

    }

    trace (sortIndicator);

    trace ("sortIndicatorInstance:" + sortIndicatorInstance);

    column: GridColumn = const 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 the 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;

    }

    on the other

    {

    If (sortIndicatorInstance)

    {

    sortIndicatorGroup.removeElement (sortIndicatorInstance);

    sortIndicatorGroup.includeInLayout = false;

    sortIndicatorInstance = null;

    }

    }

    }

    }

    private var chromeColorChanged:Boolean = false;

    private var colorized: Boolean = false;

    /**

    * @private

    * Apply the chromeColor style.

    */

    override the updateDisplayList(unscaledWidth:Number,_unscaledHeight:Number):void function

    {

    trace ("update list display");

    Apply the color chrome

    If (chromeColorChanged)

    {

    var chromeColor:uint = value ("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 reverse colorization 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 on 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)

    {

    internship. 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 >

    < name s: State = "normal" / >

    < name s: State = "flat" / >

    < name s: State = "low" / >

    < / s: states >

    <!-layer 1: shadow->

    <!---@private-->

    < s:Rect id = "shadow" left = "-1" right = "-1" high = low '-1' = '-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 = low "0" = "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 = '0 x 929496'

    Alpha = "0.85" / >

    < / s:LinearGradient >

    < / s:fill >

    < / s:Rect >

    <!-layer 3: filling lowlight->

    <!---@private-->

    < s:Rect id = "lowlight" left = "0" right = "0" top = low "0" = "0" >

    < s:fill >

    < s:LinearGradient rotation '270' = >

    < s:GradientEntry color = "0x000000" ratio = "0,0" alpha = "0,0627" / >

    < s:GradientEntry color = "0x000000" ratio = alpha '0.48' = "0,0099" / >

    < s:GradientEntry color = "0x000000" ratio = alpha "0.48001" = "0" / >

    < / s:LinearGradient >

    < / s:fill >

    < / s:Rect >

    <!-layer 4: highlight of fill->

    <!---@private-->

    < s:Rect id = "highlight" left = "0" right = "0" top = low "0" = "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: race to highlight (all States except down)->

    <!---@private-->

    < s:Rect id = "highlightStroke" left = "0" right = "0" top = low '0' = '0' excludeFrom 'low' = >

    < 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 of the stroke (to the low State only)->

    <!---@private-->

    < s:Rect id = "hldownstroke1" left = "0" right = "0" top = low "0" = "0" includeIn = "bottom" >

    < 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 down = '1' = '1' includeIn = "bottom" >

    < 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 = low "0" = "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 >->

    <!-< right '7' = left s:VGroup = '7' high low = '5' = '5' gap = "6" verticalAlign = "middle" >

    < s:TextInput width = "100%" / >

    < s:HGroup width = "100%" >

    < s:Group id = "labelDisplayGroup" width = "100%" / >

    < s:Group id = includeInLayout = "false" "sortIndicatorGroup" / >

    < / s:HGroup >

    < / s:VGroup >->

    < s:VGroup verticalAlign = "middle" left = "7" = "5" top right = '7' low gap '5' = '2' = >

    "< s:TextInput id ="filterInput"width ="100% "visible ="false"includeInLayout = 'false' keyUp =" onKeyUp (event) "Focusout/focusouthandler() =" 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 = includeInLayout = "false" "sortIndicatorGroup" / >

    < / s:HGroup >

    < / s:VGroup >

    < / s:GridItemRenderer >

    You can use 'alt' or 'Ctrl' click and just check on the event to see if one of these is 'true '.

  • DataGrid column name problem

    Salvation;

    I am new to flash ACE.

    DataGrid column name codes...

    Code:

    var dp:DataProvider = new DataProvider();
    dp.addItem ({column1: 'xx', Column2: "xx", column3: 'xx'});

    works fine but if I am the change of name of column to numeric value (for example: 32) gives me error...
    DataGrid is not supported numeric value?

    Thanks for the help...

    Use a string like: '5 '.

    dp.addItem ({"5": "xx", Column2: "xx", column3: 'xx'});

  • validation in a datagrid column

    Hello

    Is it possible to validate the datagrid column or cell.

    Help, please

    Thank you
    Kumar

    Thank you peterent

    It works

  • DataGrid column widths go crazy!

    Hi all

    I implement my own rendering engine customized to be used in the DataGrid - it works by instantiating another UIComponent and add as a child. Evrything works fine in a datagrid, but within another column widths are being reset at 20.125 as soon as I scroll - my component updateDisplayList method gets the parameters like width = 20.125 (always!), but the height seems to be OK. Scroll and down a few times seems to correct the problem, but it's not a viable solution.

    Any ideas what's happening? At this point seems to be a bug in the DataGrid code, debugger indicates any width of column as 20.125

    Never mind... my bad. A prop columns linking to an another datagrid columns and which was screwing the widths.

  • Question of DataGrid column

    I have a problem with my datagrid columns fill it with content.

    Here is the xml structure:

    Code:
    < title > Bridgeport whipper snap < / headline >
    < blurb > text < / blurb >
    location_url > whipsnap.swf < / location_url >
    < location_url_videotype > 1 < / location_url_videotype >
    < podcast_url_videotype > 2 < / podcast_url_videotype >
    < owner id = "325" name = "Bridgeport" / >

    And here's what I do:

    MXML code:

    < mx:DataGrid id = "movies" dataProvider = "{filterPlay}" width = "650" x = "50" y = "100" editable = "true" change = "previewMovie ()" >
    < mx:columns >
    < mx:DataGridColumn dataField = "headline" headerText = "Movie" editable = "false" / >
    "< mx:DataGridColumn dataField="owner.@name "headerText ="COMPANY"editable ="false"/ >
    < / mx:columns >
    < / mx:DataGrid >

    The owner.@name fill the column... just like owner@name, or @name. How can I get the name attribute of the tag owner to fill a column?

    Thank you!

    http://www.ask.com/Web?q=trainsimpleonline&o=1517&VFR=1

    Found what need me here. Thank you!

  • ItemRenderer in a datagrid column setStyle() does nothing to the appearance

    I have an ItemRenderer in a datagrid column, however the setStyle() does nothing to the appearance. When it is called. Any ideas?

    < mx:DataGridColumn dataField = "space" width = "50".
    headerText = "Space" >
    < 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 rendering engine code seems a bit strange. This works and can help you get started:

  • Automatically sort columns

    Hello

    I have a column with a number of figures for names that changes according to the entry on a separate table. It is sort of have this kind of column down automatically without having to click each me time change of numbers?

    Thank you

    Rob

    Hi Rob,

    The way I would like to address the issue is to create an index column in your original table that would rank the values that you want to sort.

    C2 = RANK (B2, B, 0)

    It is filled down.

    This index is used to retrieve the values in a report table that is already sorted.

    A2 = INDEX (entry::A, CORRESPONDENCE data (LINE (cell) −1, data entry: $C, 0),-l' the index of the column, area-index)

    It is filled down and across.

    Quinn

  • DataGrid column widths

    Hello.

    I have a working datagrid... example below.

    Please can someone help me modify this code so that I can adjust the width of each column so that it matches the size of the text in this column. At present, all columns the same width, and they do not expand in width to adjust the text in the table.

    function dataGridFunction() {var characters: Array = new Array (new Array ("Jerry Seinfeld", "35", "37.9", "+" 2.9))}

    new Array ("Chuck Norris", "35", "24", "11").

    new Array ("Jim Raynor", "35", "40", "+ 5"));

    //

    //

    for (var i: Number = 0; i < characters.length; i ++) {}

    var firstName:String = character [i] [0];

    var lastName:String = character [i] [1];

    var price: String = character [i] [2];

    var diff:String = [i] characters [3];

    dataGridMain.addItem ({name: name, TH: lastName, TR:award, VS: diff});

    }

    dataGridMain.setStyle ("fontFamily", "Verdana");

    dataGridMain.setStyle ("headerColor", "0xA6CBDD");

    dataGridMain.setStyle ("alternatingRowColors", ["0xF0F0F0", "0xFFFFFF"]);

    dataGridMain.setStyle ("rollOverColor", "0xDCEBF1");

    dataGridMain.setStyle ("selectionColor", "0xFFF97D");

    dataGridMain.setStyle ("selectionDuration", 300) ;}

    dataGridFunction();

    Thank you. My datagrid is wide 240. I took this first line and added that "BOLD". Everything seems to work ok now for all 4. The first line is important somehow.

    dataGridMain.getColumnAt (0) .width = dataGridMain._width - 240;

    dataGridMain.getColumnAt (0) .width = 120;

    dataGridMain.getColumnAt (1) .width = 35;

    dataGridMain.getColumnAt (2) .width = 35;

    dataGridMain.getColumnAt (3) .width = 35;

  • Leak memory causing module DataGrid column

    Hi all

    I have problems with a column of the DataGrid preventing a module to be communicated properly. I can't imagine that this is the intended behavior.

    Using this simple test case, a WindowedApplication and a mx:Module I wonder if anyone can reproduce this problem. The problem disappears if you simply comment the GridColumn Instance.

    Can anyone offer advice?

    Thank you very much

    James

    DataGridTest.mxml

    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                           xmlns:s="library://ns.adobe.com/flex/spark" 
                           xmlns:mx="library://ns.adobe.com/flex/mx">
        <fx:Script>
            <![CDATA[
                import mx.core.IVisualElement;
                import mx.events.ModuleEvent;
                import mx.modules.IModuleInfo;
                import mx.modules.ModuleManager;
    
                private var assetModule:IModuleInfo;
                protected function load_clickHandler(event:MouseEvent):void
                {
                    assetModule = ModuleManager.getModule('DataGridTestModule.swf');
                    assetModule.addEventListener("ready", getModuleInstance);
                    assetModule.load();
                }
                public function getModuleInstance(event:ModuleEvent):void 
                {
                    var sm:DisplayObject = assetModule.factory.create() as DisplayObject;
                    sm.addEventListener("close", closeModule);
                    contentHolder.addElement(sm as IVisualElement);
                }
                private function closeModule(event:Event):void 
                {
                    event.target.removeEventListener("close", closeModule);
                    contentHolder.removeElement(event.target as IVisualElement);
                    assetModule.unload();
                    assetModule = null;
                }
            ]]>
        </fx:Script>
        <s:VGroup width="100%" height="100%">
            <s:HGroup >
                <s:Button id="load" label="Load" click="load_clickHandler(event)"/>
            </s:HGroup>
            <s:BorderContainer id="contentHolder" width="100%" height="100%"/>
        </s:VGroup>
    </s:WindowedApplication>
    

    DataGridTestModule.mxml

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" 
                          xmlns:s="library://ns.adobe.com/flex/spark" 
                          xmlns:mx="library://ns.adobe.com/flex/mx" 
                          layout="absolute" xmlns:components="components.*">
        <fx:Script>
            <![CDATA[
                protected function close_clickHandler(event:MouseEvent):void
                {
                    dispatchEvent(new Event('close', true, false))
                }
            ]]>
        </fx:Script>
        <s:BorderContainer id="contacts"
                           width="100%" height="100%"
                           backgroundAlpha="0"
                           borderVisible="false">
            <s:layout>
                <s:VerticalLayout/>
            </s:layout>
            <s:Button id="close" label="Close" click="close_clickHandler(event)"/> 
            <s:DataGrid id="queries" >
                <s:columns>
                    <s:ArrayList>
                        <s:GridColumn/> <!-- Comment out this GridColumn instance to see the leak disappear -->
                    </s:ArrayList>
                </s:columns>
            </s:DataGrid>
        </s:BorderContainer>
    </mx:Module>
    

    Just declare a type varialbe GridColumn in the main application somewhere (and import GridColumn)

  • Cannot set the DataGrid column width

    I am very frustrated with the DataGrid control and I don't understand why it won't work. I followed the tutorial "Build year Application In An Hour" by Adobe and finally managed to extract data from a database in a DataGrid control, the data very well, but all the columns are the same width and will not change when creating. Of course I can drag the column widths when the DataGrid control has made, but you shouldn't do that. The columns are not enough even wide to fit in the title of each column. The tutorial mentioned resizing of columns, but does not specify how. I've manually entered in the < S:GridColumn > tags and entered like width = "800" see no change. I changed the width of the data grid itself, I even tried setting the width to 100%. I also went in the "Configure columns" dialog, and then in advanced and set a minWidth, but it still doesn't work, I even disabled 'resize' and still nothing. I also tried different combinations of the aforementioned attempts.

    How can it be difficult to set the width of a column?

    I should also mention that I use Adobe Flex Builder 4.5 for PHP.

    Well, I solved the problem and I'm very embarrassed to say that it is my browser cache. It was not show my saved new, which is a bit worrying plans sometimes that I need to change the small values and run my application every 10 seconds to see the update.

  • Help with the creation of the Datagrid column

    I am trying to get a better understanding of the way the Spark DataGrid works so that I can create and version extended for one of my projects. One of the things that really left me speechless is how the datagrid sets up the columns based on the dataprovider when no explicit column is defined. I was able to debug through the initialization of the datagrid to the point where the setter for dataprovider is called. At this point, my debug trace goes "down the rabbit hole" so to speak and when she returns, the columns are initialized but I can't figure out how. Could someone tell me please to the class or function that is actually responsible for creating the columns of the dataprovider if they are not defined explicitly?

    So, as you have discovered, the Grid method / generateColumns (private) is called if the list of columns is always set to null when the commitPropertes().   Subsequently becomes the columns property, as a consequence of the liaison, should update the list of columns as expected.

    Could create an example that illustrates the problem you meet?   I'd be happy to look at it.

    -Hans

  • DataGrid column indicated as a hyperlink using htmlText

    Hello

    Sincere apologies for posting this Thread.

    I'm ashamed to post this question as effortlessly, but don't have any other option that all sites on my place of work are blocked
    except for technology providers.

    Can someone post an example of code where a particular column of the DataGrid is displayed like a Hyper link using htmlText.

    I want to know how to use a converter of element in this case.

    still hoping for the best.

    Thanks for reading.

    
    
    
        
            
                
                    Google
                    http://www.google.com
                
                
                    Adobe
                    http://www.adobe.com
                
                
                    Yahoo
                    http://www.yahoo.com
                
            
        
    
        
            
                
                    
                        
                            
                        
                    
                
                
                    
                        
                            
                                
                                
                                
                            
                        
                    
                
            
        
    
    

    try this

  • Need to replace data in certain cells in DataGrid columns.

    This should be simple, but I seem to be struggling with it.

    I have a DataGrid with DataGridColumns sets and DataGrid has a DatProvider.

    All I want to do (through ActionScript) is to manipulate and update specific cells in the control DataGrid, er dataGridColumns.

    Thank you all...

    -

    FD

    You need to write code that manipulates the dataProvider, not the DataGrid itself, then the dataGrid will update automatically (if you are using data binding).

    TIP: try to use a collection (collection ArrayCollection or XMLCollection) whenever possible. Use the refresh() method to trigger the data binding.

    Here is an example:


    http://www.Adobe.com/2006/mxml"layout ="vertical"creationComplete =" init () ">"
       
            Import mx.collections.ArrayCollection;
               
    [Bindable]
    private var dp:ArrayCollection;
               
    private function init (): void
    {
    var arr:Array = [{v1: 1, v2: 2, v3: 3},]
    {v1: 4, v2: 5, v3: 6},
    [{v1: 7, v2: 8, v3: 9}];
    DP = new ArrayCollection();
    DP.source = arr;
    }
               
    private function handleNewValue (): void
    {
    DP.source [rowSetter.Value - 1] ['v' + String (colSetter.value)] = valSetter.value;
    DP. Refresh();
    }
    ]]>
       

       
           

               
               
               
           
       
       
       
           
               
           

           
               
           

           
               
           

           
               
           

       

Maybe you are looking for