2012-09-25 79 views
3

我很新。爲Android設備構建「Flex應用程序」移動應用程序。 運行最新的Flex/FlashBuilder(4.6)。Flex 4.6:無法將<mx:DataGrid>解析爲組件實現

綜觀項目屬性: 建設者:Flex的& AIR應用程序生成器 Flex編譯:「使用默認SDK(目前的‘Flex 4.6.0’) 在我的設計視圖我絕對不看MX DataGrid控件。我從過去的例子在此頁上粘貼代碼添加控制到我的應用程序: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf66ce9-7ff2.html

當我編譯我得到這個錯誤:「無法解析到一個組件實現」這是我的代碼:

<?xml version="1.0" encoding="utf-8"?> 
<!-- dpcontrols/DataGridPassData.mxml --> 
<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" 
        title="Jobs List"> 
      <fx:Script> 
        <![CDATA[ 
           import mx.collections.*; 
           private var DGArray:Array = [ 
             {Lease:'Bagby Heirs', Well:'1', Location:'Quitman', Customer:'Fair Oil Company', ScheduleDate:'2/23/2012', ServiceDate:'5/16/2012'}, 
             {Lease:'ITU', Well:'301', Location:'Ingram Trinity', Customer:'Southwest Operating, Inc.', ScheduleDate:'3/19/2012', ServiceDate:'4/25/2012'}, 
             {Lease:'ITU', Well:'81', Location:'ITU', Customer:'Southwest Operating, Inc.', ScheduleDate:'3/19/2012', ServiceDate:'4/25/2012'}, 
             {Lease:'Tolliver A', Well:'5', Location:'Turner Town', Customer:'SEDI', ScheduleDate:'4/16/2012', ServiceDate:'5/11/2012'}, 
             {Lease:'W R Cady', Well:'1', Location:'Coffield', Customer:'Green River Resource', ScheduleDate:'5/9/2012', ServiceDate:'4/10/2012'}, 
             {Lease:'Royal National Bar', Well:'2', Location:'Coffield', Customer:'Green River Resource', ScheduleDate:'5/9/2012', ServiceDate:'4/10/2012'}, 
             {Lease:'Pan American L', Well:'1', Location:'Chandler', Customer:'East Texas Oil & Gas', ScheduleDate:'5/14/2012', ServiceDate:'6/8/2012'}, 
             {Lease:'Paluxy B Sand', Well:'5', Location:'West Tyler', Customer:'Culver & Cain', ScheduleDate:'6/1/2012', ServiceDate:'5/25/2012'}, 
             {Lease:'Wh Pittman Hei', Well:'2', Location:'Quitman', Customer:'Southwest Operating, Inc.', ScheduleDate:'7/10/2012', ServiceDate:'6/18/2012'}, 
             {Lease:'Vivian Pruitt', Well:'1', Location:'Crow - Hwy 80M', Customer:'Buffco Productions, Inc.', ScheduleDate:'8/7/2012', ServiceDate:'8/29/2012'} 
           ]; 

           [Bindable] 
           public var initDG:ArrayList; 

           //Initialize initDG ArrayList variable from the Array. 
           //If you use this technique to process an HTTPService, 
           //WebService, or RemoteObject result, use an ArrayCollection 
           //rather than an ArrayList. 
           public function initData():void { 
             initDG=new ArrayList(DGArray); 
           } 
        ]]> 
      </fx:Script> 
      <!--s:states> 
      <s:State name="loginState"/> 
      <s:State name="State1"/> 
      </s:states--> 

      <fx:Declarations> 

        <!-- Place non-visual elements (e.g., services, value objects) here --> 
         <fx:Component className="AlertMsgDay"> 
           <s:SkinnablePopUpContainer x="70" y="300"> 
             <s:TitleWindow title="Filtering" close="close()"> 
                <s:VGroup horizontalAlign="center" paddingTop="8" paddingBottom="8" paddingLeft="8" paddingRight="8" gap="5" width="100%"> 
                  <s:Label text="This button will filter jobs to show only TODAY."/> 
                  <s:Button label="OK" click="close()"/> 
                </s:VGroup> 
             </s:TitleWindow> 
           </s:SkinnablePopUpContainer> 
        </fx:Component> 

        <fx:Component className="AlertMsgWeek"> 
           <s:SkinnablePopUpContainer x="70" y="300"> 
             <s:TitleWindow title="Filtering" close="close()"> 
                <s:VGroup horizontalAlign="center" paddingTop="8" paddingBottom="8" paddingLeft="8" paddingRight="8" gap="5" width="100%"> 
                  <s:Label text="This button will filter jobs to show only THIS WEEK."/> 
                  <s:Button label="OK" click="close()"/> 
                </s:VGroup> 
             </s:TitleWindow> 
           </s:SkinnablePopUpContainer> 
        </fx:Component> 

      </fx:Declarations> 

      <s:BorderContainer x="10" y="111" borderColor="#808080" cornerRadius="5" borderWeight="2" width="98%" height="369"> 
        <s:Scroller width="100%" height="363" verticalScrollPolicy="on"> 
           <s:Group width="100%" height="100%"> 


             <mx:DataGrid id="myGrid" width="900" height="350" dataProvider="{initDG}" > <<<< THE ERROR IS HERE 
                <mx:columns> 
                  <mx:DataGridColumn dataField="Lease" /> 
                  <mx:DataGridColumn dataField="Well" /> 
                  <mx:DataGridColumn dataField="Location" /> 
                  <mx:DataGridColumn dataField="Customer" /> 
                  <mx:DataGridColumn dataField="ScheduleDate" headerText="Schedule Date" /> 
                  <mx:DataGridColumn dataField="ServiceDate" headerText="Service Date" /> 
                </mx:columns> 
             </mx:DataGrid> 

           </s:Group> 
        </s:Scroller> 
      </s:BorderContainer> 

      <s:Label x="10" y="10" width="96" height="53" fontSize="24" text="Sort by:" 
           verticalAlign="middle"/> 
      <s:Button id="btn_show_today" x="104" y="11" width="105" height="53" label="Today" 
           fontSize="13" fontWeight="bold" click="(new AlertMsgDay()).open(this, false);"/> 
      <s:Button id="btn_show_week" x="216" y="11" width="105" height="53" label="Week" 
           fontSize="13" fontWeight="bold" click="(new AlertMsgWeek()).open(this, false);"/> 
      <s:Button x="348" y="10" width="184" height="53" label="Edit this Job" fontSize="18" click="navigator.pushView(views.JobFormView);"/> 
</s:View> 
+1

而不是使用mx DataGrid,請嘗試使用spark一個。開箱即用。雖然性能沒有更好。移動設備的速度仍然太慢。我的建議是,使用'List'和'LabelItemRenderer'來模擬網格外觀。 – AlBirdie

+0

謝謝!我在哪裏尋找自定義渲染器? – ScotterMonkey

回答

2

mx:DataGrid不是移動優化組件,除非明確添加MX SWC,否則不會出現在Flex Mobile項目中。 MX SWC應位於您的框架目錄中。

查找範圍

[Flex Framework directory]\frameworks\libs\mx\mx.swc

如果您使用的是默認的Flash Builder中安裝在Windows上;那麼你的Flex框架目錄將可能是這樣的:

C:\Program Files (x86)\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0

您可以在項目設置Flex構建路徑頁的SWC添加到您的庫路徑。

我不希望在移動設備上的MX DataGrid中獲得非常好的性能,但我聽說過有人用它獲得成功。

+0

它的工作!謝謝!還有一個問題:是否有一個你會推薦使用的控件,在移動設備上更好? – ScotterMonkey

+0

你可以試試Spark DataGrid;儘管這不是移動優化的。您可能適合使用列表和自定義渲染器。 – JeffryHouser

相關問題