flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Deepak MS (JIRA)" <j...@apache.org>
Subject [jira] [Created] (FLEX-34404) Ability to add MobileGridColumns dynamically to MobileGrid
Date Wed, 09 Jul 2014 12:37:04 GMT
Deepak MS created FLEX-34404:
--------------------------------

             Summary: Ability to add MobileGridColumns dynamically to MobileGrid
                 Key: FLEX-34404
                 URL: https://issues.apache.org/jira/browse/FLEX-34404
             Project: Apache Flex
          Issue Type: New Feature
          Components: Mobile: DataGrid
    Affects Versions: Apache Flex 4.12.0
            Reporter: Deepak MS
            Assignee: Maurice Amsellem


Basically, I am calling a query which gives me a result set(ArrayCollection). Based on the
columns I receive in this AC, I am dynamically creating MobileGridColumns and storing this
a model's array variable. This variable is binded to MobileGrid's columns property in my view.

I created a simple case
below:
<?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" title="Home" xmlns:ns="
http://flex.apache.org/experimental/ns"
creationComplete="view1_creationCompleteHandler(event)">

    <s:layout>
        <s:VerticalLayout verticalAlign="top" horizontalAlign="left"/>
    </s:layout>
    <fx:Declarations>

    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.FlexEvent;

            import spark.components.supportClasses.MobileGridColumn;
            private var serviceData:ArrayCollection = new ArrayCollection([
                {geo:'Geo1', sales:123342, target:12324},
                {geo:'Geo2', sales:3423342, target:384324},
                {geo:'Geo3', sales:3234342, target:12324},
                {geo:'Geo4', sales:673342, target:34324},
                {geo:'Geo5', sales:853342, target:72324},
            ]);
            [Bindable]private var dp:ArrayCollection = new ArrayCollection();
            [Bindable]private var cols:Array = [];

            protected function
view1_creationCompleteHandler(event:FlexEvent):void
            {
                var newCols:Array = [];
                if(serviceData.length > 0)
                {
                    for(var colName:String in serviceData[0])
                    {
                        var mgc:MobileGridColumn = new MobileGridColumn();
                        mgc.dataField = colName;
                        mgc.width = 300;
                        newCols.push(mgc);
                    }

                    cols = newCols;
                }

                for each(var item:Object in serviceData)
                {
                    dp.addItem(item);
                }
            }

        ]]>
    </fx:Script>


    <ns:MobileGrid width="100%" height="100%" dataProvider="{dp}"
columns="{cols}"/>
</s:View>




--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message