PDA

View Full Version : Grid row blanks-out after update (CRUD)



Mike Robinson
16 Sep 2009, 2:29 PM
I had this working... what the heck did I do? :(

I am using a JSONReader and JSONWriter to implement "straight CRUD," and what happens is that an updated or inserted record goes blank (in the grid display). ExtJS really does think that the record consists entirely of blanks.

The store definition (in funky ColdFusion "coldext" syntax:

<ext:Store
var="gridStore"
autoLoad="true"
remoteSort="false"
url="crv2_js.cfc"
baseparams=" {
method: 'GridSource_ReviewPrototypes',
returnFormat: 'JSON'
}"
reader="
new Ext.data.JsonReader(
{
root: 'data',
idProperty: 'prototypeid'
},
[
{ name: 'id', mapping: 'prototypeid' },
{ name: 'TemplateName', mapping: 'templatename' },
{ name: 'PrototypeClassName', mapping: 'prototypeclassname' },
{ name: 'EnabledFlag', mapping: 'enabledflag', type: 'boolean' },
{ name: 'DefinitionIsLocked', mapping: 'definitionislocked', type: 'boolean' },
{ name: 'Description', mapping: 'description' },
{ name: 'ClonedFromPrototypeName', mapping: 'clonedfromprototypename' }
]
)"
passthrough="
writer: new Ext.data.JsonWriter(
{
}
)"
autoSave = "true"
>
Here's the packet that is sent: (cleaned-up for clarity)


data: { description: "doo", prototypeid: 66 }
method: GridSource_Prototypes
prototypeid: 66
returnFormat: JSON
xaction: update
... and here's the response:


{"success":true,"data":[{"prototypeid":66.0}],"count":1}


So... we have a correct request (properly presented as "update" so we know it's not a phantom), and a correct response. But it seems that instead of merging the returned field-values into the existing record, they're all being replaced.

Mike Robinson
17 Sep 2009, 5:15 AM
Well, feeling a bit like the Little Red Hen here, I have traced through the long stretch of code that flows from Store to DataProxy/HttpProxy by way of the Reader and the Writer, and (looking at HttpProxy::onWrite) I see that there is a write event that is fired as a fairly obvious debugging-hook. That should give me the means to ascertain what is happening ... I hope!

I know that the next step from this point is that Store's after-update handler gets called and that it, in turn, calls the Reader's update method.

Stay tuned. I'll post what I find.

Mike Robinson
19 Sep 2009, 8:13 PM
Bump?

Animal
20 Sep 2009, 11:59 AM
All I can suggest is to find the line



onWrite : function(action, o, response, rs) {


In ext-all-debug.js in the Firebug debugger, and set a break in the first line of that function.

This is the only way to debug Ajax. You have to set a breakpoint in the callback.

You will be able to see how it processes your response and ends up inserting the Record.

Mike Robinson
20 Sep 2009, 7:48 PM
It doesn't insert a record. On the back end, it correctly updates the record. But in the display the grid row becomes blank upon return of the reply. I have not yet pursued debugging this one quite yet, partly because it used to work so I've got it marked as "stoopid me." ;)

Animal
20 Sep 2009, 9:56 PM
You can debug that by setting a breakpoint at



refreshRow : function(record){


See what's passed, and go back through the call stack to see who sent it.

Dustin Graham
12 Oct 2009, 7:57 PM
I have this same problem. I'm not sure what happened or why.

Essentially I have a gridpanel with a ux.bufferview and when double clicking a grid row, it takes the user to another tab.

I only noticed my grid row was blanking out after I added a (by saki) ux.checktreepanel to my other tab panel. But, now when I do any sort of edit to the common datastore, the particular record that was modified blanks out in the gridpanel.

If I scroll up or down in the grid panel, the row appears again.

Not sure why the row temporarly blanks out. I can click on another row and my summary panel has the right data, then if i click on the blank row, the summary panel still displays the correct data from the record. It just doesn't show the data in the grid row until scrolling in the grid panel box.

MMm......

[EDIT/UPDATE]
Well... I noticed that if (while debugging) I swapped the tab panel to display the grid panel before calling the data store updates, that the grid row didn't blank out.

Therefore, I figured maybe the grid required that it was displayed during the datastore update? Not sure.

In any case, I added a listener to the tabPanel's activate event. And when activate is fired, I simply call bufferView.refresh(); which solves the blank row problem. I don't think calling refresh whenever switching to the grid panel tab creates any noticeable delay in switching tabs. So, this works for me.