PDA

View Full Version : store.removeAll() error on 4.2.1 but works fine on 4.1.1



Scott Mildenberger
9 Apr 2014, 12:44 PM
There is a fiddle showing this at https://fiddle.sencha.com/#fiddle/4uj , if you run under 4.2.1 it has a problem that doesn't occur under 4.1.1.

How it is to work:
I have a grid with grouping. I have attached a group context menu which has a choice of 'Edit'. When Edit is clicked (calls getRec()) a form is displayed that has another grid (editable) which has all the detail of the transaction. I add a couple of blank rows to this grid in case items need to be added. Within this procedure getRec() I use store.removeAll() on the store that the editable detail grid is tied to, then I add the detail for this record and the blank rows.

The problem:
If you right click a group and choose Edit, then click inside one of the cells of the 'added blank rows' (in my example row 2 or more as the detail always has only one row). Leave the cursor in that position. Then click 'Cancel'. Then right click and choose Edit again - on the Console I get 'Uncaught TypeError: Cannot call method 'getId' of undefined on line 126070 of ext-all-debug.js which is inside onViewRefresh(). I have tracked back that this is inside my call to store.removeAll(). You will notice when the error happens the screen is never unmasked as it doesn't get to that line in the script.

If you click in Row 2 then click back in Row 1 before doing 'Cancel' then the error does not occur, only when the cursor has been left in one of the added 'blank' rows. If you run this under 4.1.1 there is no error either.

This is confusing to explain so hope I have made clear enough, maybe by looking at the fiddle it will make enough sense.

Thanks,

Scott

Gary Schlosberg
10 Apr 2014, 12:51 PM
Thanks for the detailed report. This issue seems to have been resolved in 4.2.2. Your test case works fine in that version, as well as the latest nightly release of 4.2.3 and 5.0.0 beta.

Scott Mildenberger
10 Apr 2014, 1:16 PM
Gary,Thanks for the info. We are using this through our license of CNX's Valence product so I have to wait until the upgrade to a later version. I will let them know. Is there a work around for now to remove all the records in a store? I was thinking of looping through all the records and do a .remove() on each one. Is that the best bet?Thanks,

UPDATE: I put in a store.removeAt(0, numRecords); and this worked but now I get the error on the store.Add() function. In the version I am at how do I empty a store and then add records back into it?

Scott Mildenberger
11 Apr 2014, 7:17 AM
I was able to finally get this to work ok. I resorted to using store.loadData(). I just had to use the append parm and set it to false for the first row and true for the rest of the rows. This works in the fiddle so I will now put into my app. Don't know if this is the best work around but it does work.