View Full Version : Confusing and Performance difference between store.add and store.data.add

5 Dec 2011, 5:29 AM

I'm really confused between store.add() and store.data.add() method. I's experiencing performance issue with bulk data insertion in my editorgridpanel. (as mentioned in http://www.sencha.com/forum/showthread.php?156819-Performance-Issue-Bulk-data-Inesrtion-in-EditorGrid).

Though the thread, suggets to use suspendEvents and resumeEvent, but doesnt brought any significant performance improvements. As an alternate solution, I used store.data.add() instead of store.add() which gave incredible performance. But, there was some hidden issues in using store.data.add() and as follows:

I have an editoregridpanel. I duplicated some existing records into the grid, using store.data.add(). Now, if I click on the editable cell of the newly copied record and type-in some values, then on the onblur of that particular cell, the value get restored to its previous value (ie, value before editing). If I click again on the editable-cell, then in the edit-mode of that cell, I can see my original typed-in value and again on the onBlur, it restores its original value.

To solve this, on cell's afterEdit event, I refreshed the gridview, which solves the above mentioned problem.

So I conclude that on using store.data.add() method, I'm missing to re-register some events, which is causing the cell's updation problem.

Here comes my doubt:
1. What is the difference between store.add and store.data.add?
2. store.data.add() has a significant performance over store.add(). Why?
3. Is store.data.add() can be used? If so, what all events I need to re-register and what all events I need to bother about? Do I need to regiter the events for grid, store AND columnmodel?
4. Why the cell does not detain value when I added records using store.data.add()?

These are all my finding and concerns.
Is there any better way to add bulk records into the store without any drop-in-performance?

Any help will be appreciated.
Looking forward for valuable responses.

5 Dec 2011, 7:46 AM
store.data.add is not an official supported method.
imho there is a lot missing if you just call it and it will have the same speed as store.add if you add all the missing parts manually.

that being said, i would put all records you want to add into an array and add the array with one add call. if you have to go for multiple calls, suspending the events has an effect.

5 Dec 2011, 9:38 PM
Hello Tobias,

That was tricky.
I added all the records into an array and passed to the store object. Now, it has significant performance improvement.

Thanks. :)