14 Replies Latest reply on Jun 5, 2011 9:39 AM by Margish Kotadiya

    Duplicate rows in DataGrid in Flex3/LCDS2.5

    olegkon
      Hi,

      My project in Flex2/LCDS2 uses DataGrid very extensively with streaming data coming in.
      After we recompiled it with Flex3 and run with LCDS2.5, we see a strange behavior:
      originally it shows everything right, but all coming data creates duplicate rows.
      As soon as we do sort on any column, duplicates disappear.
      But then again new data creates duplicate rows...

      We have never seen that happening with Flex2,
      in fact it's running fine in production for a few months.

      Has anybody seen such behavior ?
      How can we cure that ?
      (we do not do any special processing on that data, so I really doubt it's anything in our code)
      (using Java 1.5 on the server).

      Any help is very appreciated.

      Thank you in advance,
      Oleg.


        • 1. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
          alice_data Level 1
          Hi,

          I think I am having a similar experience too, although I am using Flex 3. I have just posted my question a few minutes ago. Does this sound like yours?

          Alice
          • 2. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
            olegkon Level 1
            Alice,

            At least from your description I don't see how our problems are related.
            I do not use PHP or HTTPService, but Flex2 DataGrid collections, LCDS & Java on backend.
            Please explain in more details if you disagree.

            Thanks,
            Oleg.
            • 3. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
              alice_data Level 1
              Hi,

              Maybe you are right. The nature of our problem may be a little different, but I also see duplicate rows being generated when they are not supposed to be according to my back-end coding and they get displayed on my DataGrid just as you described above. I even tried to echo back the variables I passed to the HTTPService request, and they bring back the way they should be instead of all the entries.

              I am experiencing some problems myself that I cannot explain from what I see from my DataGrid, since those rows get generated only through Flex, but they don't when I just run it from PHP.

              Perhaps you might be able to tell me how I could solve my problem here?

              Alice
              • 4. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
                Karl_Sigiscar_1971 Level 3

                Hi,

                I did have this problem.

                The only solution I could find is to :

                1. Create a new collection as the data provider for the datagrid. Don't assign directly the collection coming from the server

                2. Define a <Binding> tag in order to detect changes to the collection and set the destination to a setter function

                3. In the setter, reset the dataprovider collection, go through each element in the incoming collection from the server, check if the element is already present in the dataprovider collection based on the entity key and add it if not present.


                • 5. Duplicate rows in DataGrid in Flex3/LCDS2.5
                  Nirvish_Patel
                  Hi Olegkon,

                  I an facing same problem like you.
                  If you had solved this problem then please let me know.

                  I will appreciate your hlep.

                  Thank you in advance,
                  Nirvish
                  • 6. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
                    Nirvish_Patel Level 1
                    Hi Karl_Sigiscar_1971 ,

                    Could you please give me code how you implement your code to resove the problem?

                    i will apperciate your help.

                    Thanks,
                    Nirvish
                    • 7. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
                      olegkon Level 1
                      Guys,

                      We haven't resolved that problem, just planning to open a ticket with Adobe.
                      In the logs we can see that 1 row is inserted (from data stream) on Java side, and 2 identical rows are inserted in ArrayCollection on Flex side.

                      Could you please specify with which version of LCDS you have this problem ? That is important.
                      As for us, it worked fine until we started using 2.6.0 with Flex3
                      (I was just told that it was OK with Flex2 on LCDS2.5.1 and Java5.0).
                      With LCDS 2.6.1 still have a problem.

                      What's your story?

                      Thank you,
                      Oleg.
                      • 9. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
                        Nirvish_Patel Level 1
                        Hi,

                        I am also facing problem for LCDS2.6.0 with Flex3.
                        It is working properly in Flex2 on LCDS2.5.1 and Java5.0

                        Thanks,
                        Nirvish

                        • 10. Duplicate rows in DataGrid in Flex3/LCDS2.5
                          Karl_Sigiscar_1971 Level 3

                          Hi Nirvish,

                          Here is an example:

                          salesReportsVO is the dataprovider of the datagrid, an ArrayCollection.
                          this.model.salesReports.salesReports is the ArrayCollection filled by data from the server.
                          batchNumber is the key that uniquely identifies an item.

                          private function set onSalesReportsChanged(value:ArrayCollection):void
                          {
                          // Assign local VO
                          this.salesReportsVO = new ArrayCollection();

                          for each(var item:SalesReport in value)
                          {
                          var found:Boolean = false;

                          for each(var sr:SalesReport in this.salesReportsVO)
                          {
                          // Check if the item is already there

                          if(sr.batchNumber == item.batchNumber)
                          found = true;
                          }

                          // Add the item only if it hasn't been found

                          if(!found)
                          this.salesReportsVO.addItem(item);
                          }
                          }

                          <mx:Binding source="{this.model.salesReports.salesReports}" destination="this.onSalesReportsChanged" />
                          • 11. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
                            Nirvish_Patel Level 1
                            Hi Karl,

                            Thanks for your help. I had implement code like you but it will make performance problem. It is very slow if we have more data in gird. So have to check for other solution.

                            Hi Oleg,

                            Do you have any update on this issue?

                            Thanks,
                            Nirvish
                            • 12. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
                              Karl_Sigiscar_1971 Level 3

                              This might help:

                              Section 3 of the following article mentions the use made by Flex of UIDs:
                              http://flex.sys-con.com/node/505875

                              3. Make sure that your server-side and client-side DTOs DO provide unique set/get uuid property. Flex loves this property, do get in love with it too. Flex is using it to identify elements of data presented by the list-based controls. You will find numerous uses for it as well. For instance, instead of sorting by industry, ticker you would sort by industry, ticker and uuid. Why? Because then the hash value will be unique for each record, which would result in substantially better performance.
                              • 13. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
                                olegkon Level 1
                                Guys,

                                Here is a bug report on similar problem (although not the same) opened
                                by one of Adobe architects:
                                https://bugs.adobe.com/jira/browse/SDK-15026
                                It appears that converting DataGrid to AdvancedDataGrid might help
                                to resolve the problem. Could you try and let me know ?
                                I am currently off that project.

                                Thank you,
                                Oleg.
                                • 14. Re: Duplicate rows in DataGrid in Flex3/LCDS2.5
                                  Margish Kotadiya

                                  Just make sure you are not adding duplicating objects to your array collection.

                                  It happened to me but figured it out.


                                  If you have a loop that checks make sure you do the addIteam(obj); outside the inner loop but within the outer loop

                                   

                                  for each (......)

                                       {

                                        var match:boolean = false;

                                       for each(....)

                                            {

                                                 if(....)

                                                 {

                                                      match = true;

                                                 }

                                            }

                                  /** this is out side the inner loop */

                                            if(!match)

                                                 array.addItem(obj);

                                       } /** outer loop ends here