6 Replies Latest reply on Jan 9, 2016 9:16 AM by kglad

    How to add two datagrid controls on same form? I am getting error ..

    FlashLearner

      Hi,

       

      I need to add two datagrid controls on same page. When I try to drag another datagrid control from Components window, it says "A component with this name already exists in Library".

       

      How can I add more datagrid controls on same page?

       

      Regards.

        • 1. Re: How to add two datagrid controls on same form? I am getting error ..
          kglad Adobe Community Professional & MVP

          drag the control grid from your library to your stage.  you don't need (and can't add) another from the component panel.

          1 person found this helpful
          • 2. Re: How to add two datagrid controls on same form? I am getting error ..
            FlashLearner Level 1

            Thanks. Now the error is as following:

             

            **Warning** The linkage identifier 'fl.controls.DataGrid' was already assigned to the symbol 'DataGrid', and cannot be assigned to the symbol 'DataGrid2', since linkage identifiers must be unique.

             

            I am using the following actionscript3 code:

             

            import fl.data.DataProvider;

            import fl.controls.dataGridClasses.DataGridColumn;

            import flash.events.Event;

            import flash.net.URLRequest;

            import fl.events.ListEvent;

             

             

            var COL_SLNO:DataGridColumn = new DataGridColumn("S. No.");

            myGrid.addColumn(COL_SLNO);

            COL_SLNO.width=15

             

             

            var COL_DESCRIPTION:DataGridColumn = new DataGridColumn("Description");

            myGrid.addColumn(COL_DESCRIPTION);

            COL_DESCRIPTION.width=80

             

             

            var COL_PATH:DataGridColumn = new DataGridColumn("FILE_LOCATION");

            myGrid.addColumn(COL_PATH);

            COL_PATH.sortOptions = Array.NUMERIC;

            COL_PATH.width=1

             

             

            var allDatabase:Array = [];// contains all users like in xml

            var currentDatabase:Array = [];// contains users that need to be displayed

             

             

            var _loader:URLLoader = new URLLoader();

            var _data:XML = new XML();

             

             

            _loader.addEventListener(Event.COMPLETE, readXML);

            _loader.load(new URLRequest("Docs/Schedule/Agri/ScheduleAgri.xml"));

             

             

            function readXML(event:Event):void

            {

            _data = new XML(event.target.data);

            for each (var usr in _data.user)

            {

            allDatabase.push({id: usr.@id, SLNO: usr.@SLNO, DESCRIPTION: usr.@DESCRIPTION, PATH: usr.@PATH});

            }

            currentDatabase = allDatabase.concat();

            updateList();

            }

             

             

            function updateList():void

            {

            myGrid.dataProvider = new DataProvider ();

             

             

            for (var i:int = 0; i<currentDatabase.length; i++)

            {

            myGrid.addItem({"S. No.": currentDatabase[i].SLNO, "Description": currentDatabase[i].DESCRIPTION, FILE_LOCATION: currentDatabase[i].PATH});

            }

             

             

            //myGrid.addEventListener(Event:ListEvent.ITEM_CLICK, gridItemClick);

            myGrid.addEventListener(ListEvent.ITEM_CLICK , gridItemClick);

            function gridItemClick (e:ListEvent):void

            {

            var urlR:URLRequest=new URLRequest(e.target.getItemAt(e.rowIndex).FILE_LOCATION)

                navigateToURL(urlR, "_blank");

            }

            }

            • 3. Re: How to add two datagrid controls on same form? I am getting error ..
              FlashLearner Level 1

              Now, I change the code for the second datagrid as below:

               

              import fl.data.DataProvider;

              import fl.controls.dataGridClasses.DataGridColumn;

              import flash.events.Event;

              import flash.net.URLRequest;

              import fl.events.ListEvent;

               

               

              var COL_SLNO2:DataGridColumn = new DataGridColumn("S. No.");

              myGrid2.addColumn(COL_SLNO2);

              COL_SLNO2.width=15

               

               

              var COL_DESCRIPTION2:DataGridColumn = new DataGridColumn("Description");

              myGrid2.addColumn(COL_DESCRIPTION2);

              COL_DESCRIPTION2.width=80

               

               

              var COL_PATH2:DataGridColumn = new DataGridColumn("FILE_LOCATION");

              myGrid2.addColumn(COL_PATH2);

              COL_PATH2.sortOptions = Array.NUMERIC;

              COL_PATH2.width=1

               

               

              var allDatabase2:Array = [];// contains all users like in xml

              var currentDatabase2:Array = [];// contains users that need to be displayed

               

               

              var _loader2:URLLoader = new URLLoader();

              var _data2:XML = new XML();

               

               

              _loader2.addEventListener(Event.COMPLETE, readXML2);

              _loader2.load(new URLRequest("Docs/Schedule/Petro/SchedulePetro.xml"));

               

               

              function readXML2(event:Event):void

              {

              _data2 = new XML(event.target.data2);

              for each (var usr2 in _data2.user2)

              {

              allDatabase2.push({id: usr2.@id, SLNO: usr2.@SLNO, DESCRIPTION: usr2.@DESCRIPTION, PATH: usr2.@PATH});

              }

              currentDatabase2 = allDatabase2.concat();

              updateList2();

              }

               

               

              function updateList2():void

              {

              myGrid2.dataProvider = new DataProvider ();

               

               

              for (var i:int = 0; i<currentDatabase2.length; i++)

              {

              myGrid2.addItem({"S. No.": currentDatabase2[i].SLNO, "Description": currentDatabase2[i].DESCRIPTION, FILE_LOCATION: currentDatabase2[i].PATH});

              }

               

               

              //myGrid2.addEventListener(Event:ListEvent.ITEM_CLICK, gridItemClick);

              myGrid2.addEventListener(ListEvent.ITEM_CLICK , gridItemClick2);

              function gridItemClick2 (e:ListEvent):void

              {

              var urlR2:URLRequest=new URLRequest(e.target.getItemAt(e.rowIndex).FILE_LOCATION)

                  navigateToURL(urlR2, "_blank");

              }

              }

               

              First datagrid is woking fine but the second one gives the following error:

               

              ReferenceError: Error #1069: Property data2 not found on flash.net.URLLoader and there is no default value.

                at Schedule_fla::Messages_1/readXML2()

                at flash.events::EventDispatcher/dispatchEventFunction()

                at flash.events::EventDispatcher/dispatchEvent()

                at flash.net::URLLoader/onComplete()

              • 4. Re: How to add two datagrid controls on same form? I am getting error ..
                kglad Adobe Community Professional & MVP

                _data2 = new XML(event.target.data2);

                 

                should be

                 

                _data2 = new XML(event.target.data);

                 

                (actually, it's better if it were

                 

                _data2 = XML(event.target.data);