-
30 Apr 2009 11:47 AM #11
I've modified DataReader#realize, DataReader#update to accept Array from server when saving/creating single records.
committed to SVN.
Code:// If rs is NOT an array but data IS, see if data contains just 1 record. If so extract it and carry on. if (Ext.isArray(data) && data.length == 1) { data = data.shift(); }/**
* @author Chris Scott
* @business www.transistorsoft.com
* @rate $120USD / hr; training $500USD / day / developer (5 dev min)
*
* @SenchaDevs http://senchadevs.com/developers/transistor-software
* @twitter http://twitter.com/#!/christocracy
* @github https://github.com/christocracy
*/
-
2 May 2009 7:13 PM #12
Nice. Thanks.
I have another problem though... I already have 2 objects in the store and then add a new one with the code I detailed in that post (with all the corrections).
Here's what I get in firebug though:
Now the third record does have an id (set automatically to the server's pk). Somehow it is treated differently from the other records. It doesn't seem to affect it in any way except that its selection/deselection in a grid based on that store doesn't work well.Code:>>> App.usersStore.getAt(0) Object id=somekey1 >>> App.usersStore.getAt(1) Object id=somekey2 >>> App.usersStore.getAt(2) Object phantom=false
Basically once selected, I can select another record but the third one will not visually be deselecedt unless I Ctrl-click it.
If I destroy the grid and recreate it then the problem will go away and the output in firebug becomes the expected:
Here's the code for the grid:Code:>>> App.usersStore.getAt(0) Object id= somekey1 >>> App.usersStore.getAt(1) Object id= somekey2 >>> App.usersStore.getAt(2) Object id= somekey3
Note: the problem only occurs after I have called the save method on the store and it sets the id based on the returned PK. There is no issue with a newly added record per se.Code:var selM = new Ext.grid.RowSelectionModel({ singleSelect:true, listeners:{ selectionchange: function(sm){ if(sm.getCount()==1&&sm.getSelected().id!=App.user.id){ // something } else{ // something } } } }); var grid = new Ext.grid.GridPanel({ stateId:'app_g_users', store:usersStore, border:true, loadMask:true, stripeRows:true, viewConfig:{forceFit:true}, selModel:selM, cm:new Ext.grid.ColumnModel([ {header: "Nickname", width: 100, sortable: true, dataIndex: 'nickname'} ]), listeners:{ rowdblclick: function(){ // do something } }] });
For instance, this code alone will be fine:
The selections will work as expected until I call the store's save() function and it updates the added record with the server's PK.Code:var nRec = new userRecord({ nickname: "Test" }); usersStore.addSorted(nRec);
-
2 May 2009 7:24 PM #13
Roger, I'm on it.
/**
* @author Chris Scott
* @business www.transistorsoft.com
* @rate $120USD / hr; training $500USD / day / developer (5 dev min)
*
* @SenchaDevs http://senchadevs.com/developers/transistor-software
* @twitter http://twitter.com/#!/christocracy
* @github https://github.com/christocracy
*/
-
3 May 2009 8:11 PM #14
Also, doing the following does not return anything for a newly created record even though the key has been set and can be accessed with the id property of the record (all other records are returned just fine):
Only way to make it work is to reload the store.Code:usersStore.getById('newPKasReturnedByServer')
-
4 May 2009 6:45 AM #15
Still broken as of RC1.1 (I made the necessary changes to the code to reflect the revamped CRUD functions - the record has its ID set just fine).
Note: to go around it, I use the following (temporarily hopefully):
Code:usersStore.getAt(usersStore.find('key','newPKasReturnedByServer'))
-
11 May 2009 2:08 PM #16
Ok, she's good-to-go in SVN. Newly realized records are now re-mapped in Store's underlying MixedCollection. Big thanks to Mr LeCompte for keeping me informed and delivering to me the solution code on a platter prepared by Mr Condor.
/**
* @author Chris Scott
* @business www.transistorsoft.com
* @rate $120USD / hr; training $500USD / day / developer (5 dev min)
*
* @SenchaDevs http://senchadevs.com/developers/transistor-software
* @twitter http://twitter.com/#!/christocracy
* @github https://github.com/christocracy
*/


Reply With Quote