Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Duplicate rows in DataGrid in Flex3/LCDS2.5

olegkon
Level 1
Level 1
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.





14 Replies
alice_data
Level 2
Level 2
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
olegkon
Level 1
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.

alice_data
Level 2
Level 2
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
Karl_Sigiscar_1
Level 2
Level 2


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.





Nirvish_Patel
Level 1
Level 1
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
Nirvish_Patel
Level 1
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
olegkon
Level 1
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.
Nirvish_Patel
Level 1
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



Karl_Sigiscar_1
Level 2
Level 2


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" />

Nirvish_Patel
Level 1
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
Karl_Sigiscar_1
Level 2
Level 2


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.

olegkon
Level 1
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.

Margish_Kotadiy
Level 1
Level 1

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