2 Replies Latest reply on Jun 25, 2008 10:09 AM by matthew horn

    Multiple dataprovider instances?

    GSS1
      Hi,

      I have a datagrid in my Flex application which looks like this:

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

      [Bindable]
      public var descriptions : ArrayCollection = new ArrayCollection([
      {id: 1, string: ""},
      {id: 1, string: ""},
      {id: 1, string: ""}

      ]);

      ]]>
      </mx:Script>



      </mx:Canvas>
      <mx:Canvas label="Portfolio" width="100%" height="600" backgroundColor="#E9F2EF" verticalScrollPolicy="on">
      <mx:DataGrid x="27" y="28" height="410" width="548" dataProvider="description"
      rowCount="4" fontSize="9" fontFamily="Verdana" fontWeight="bold" color="#717577" borderColor="#CFC4C4" alternatingItemColors="[#E9F7EB, #FFFFFF]">

      <mx:Object name=" Profiler"
      creator="Profiles .NET apps" publisher="C#, .NET" link="" />



      <mx:Object name="Member Extractor"
      creator="Extracts the methods and properties of an assembly into a CSV file. This application therefore produces a high level overview of the architecture of my .NET code"
      publisher="C#, .NET" />

      <mx:Object name="Dependency Walker"
      creator="Takes an assembly file, and loads the referenced assemblies, and then recursively the referenced assemblies in thos assemblies."
      publisher="C#, .NET 3.5"/>

      <mx:Object name="Assembly Viewer"
      creator="Displays attributes about an assembly" publisher="C#, .NET 3.5" />

      <mx:Object name="eCommerce Engine"
      creator="Provides a product catalog and shopping basket functionality to allow orders to be fulfilled via a payment provider (Paypal)" publisher="C#, ASP.NET, SQL Server, .NET, CSS, UML, Paypal API" />

      <mx:Object name="Blogging Engine"
      creator="A platform to post comments, edit them, and use OPML, RSS within blogs" publisher="C#" />

      <mx:Object name="Blogging Engine (PHP5)"
      creator="A platform to post comments, edit them, and use OPML, RSS within blogs" publisher="C#" />


      <mx:Object name="Intranet (classes only)"
      creator="Provides newsletter and an employee helpdesk" publisher="C#, .NET 3.5" />

      <mx:Object name="CMS"
      creator="Allows complex, rich text updates to be made without any technical knowledge" publisher="C#, ASP.NET 3.5" />

      <mx:Object name="Classifieds Web Application"
      creator="Allows for the advertising of products" publisher="C#, .NET 3.5, ASP.NET" />

      <mx:Object name="Real Estate Web Application"
      creator="Allows for the uploading of houses and media associated with them." publisher="C#, ASP.NET .NET 3.5" />

      <mx:Object name="Project Tracker"
      creator="Allows the end user to enter time spent on projects to keep a record" publisher="C#, ASP.NET, .NET 3.5" />

      <mx:Object name="Project Tracker"
      creator="Allows the end user to enter time spent on projects to keep a record" publisher="C#, ASP.NET, .NET 3.5" />


      <mx:Object name="Bug Tracker"
      creator="Tracks bugs and their status, also reports them." publisher="C#, .NET 3.5, ASP.NET" />

      <mx:Object name="Custom Web Application"
      creator="Consists of eCommerce, auction, CMS, blogging, image gallery, algorithms" publisher="ASP.NET, C#, SQL Server" />










      <mx:columns>
      <mx:DataGridColumn headerText="Project"
      dataField="name"/>

      <mx:DataGridColumn headerText="tech"
      dataField="publisher"/>

      <mx:DataGridColumn dataField="creator" headerText="description">
      <mx:itemRenderer>
      <mx:Component>
      <mx:LinkButton click="handleClick()" label="{creator}" >
      <mx:Script>
      <![CDATA[
      public function handleClick():void{
      var url:URLRequest = new URLRequest(data.location);
      navigateToURL(url,"_blank");
      }
      ]]>
      </mx:Script>

      </mx:LinkButton>
      </mx:Component>
      </mx:itemRenderer>

      </mx:DataGridColumn>

      </mx:columns>

      </mx:DataGrid>


      When I build this project I get the warning there are multiple dataprovider property instances.

      However, in the above code I don't use the dataprovider property so what gives?

      Thanks
        • 1. Multiple dataprovider instances?
          dimival Level 1
          Ok the error is that you have an ArrayCollection as dataprovider in your datagrid and then you are using a group of objects to populate your datagrid, so you are setting two different dataproviders.

          <mx:DataGrid x="27" y="28" height="410" width="548" dataProvider="description"

          I don't quite get why you are using the descriptions array for............you don't do anything with it.

          The best would be to add your objects to the ArrayCollection and then set it as dataProvider for you DataGrid, something like this:

          public var descriptions : ArrayCollection = new ArrayCollection([
          {name: "Member Extractor", creator: "Extracts the methods and properties of an assembly into a CSV file. This application therefore produces a high level overview of the architecture of my .NET code", publisher: "C#, .NET"},
          .......])

          <mx:DataGrid dataProvider="{descriptions }">

          It is important that whenever you set a dataProvider in mxml you use the {} otherwise it won't work.

          The other option would be to remove the dataProvider statement in your DataGrid and leave the group of objects.

          For further information check the DataGrid's documentation:

          http://livedocs.adobe.com/flex/201/langref/mx/controls/DataGrid.html


          • 2. Re: Multiple dataprovider instances?
            matthew horn Level 3
            Well, dataProvider is the default property for a DataGrid, so by defining all those objects inside DataGrid, you are defining the value of the default property multiple times.

            hth,
            matt horn
            flex docs