PDA

View Full Version : Grid + Form + CRUD = update problem



waken
8 Jul 2010, 11:57 PM
Hi, i trying to create grid and form connected to one store with HttpProxy for CRUD operations.
Everythig works fine except "update"



// insert (button with click listener - "create" request)
var rec = new oStore.recordType(panelAll.getForm().getValues());
oStore.insert(0, rec);
oStore.save();

// delete (button with click listener - "destroy" request)
var gridrecord = oGrid.getSelectionModel().getSelected();
oStore.remove(gridrecord);
oStore.save();

// update - how ?
var rec = new oStore.recordType(panelAll.getForm().getValues());
panelAll.getForm().updateRecord(rec); // ???



:(
Thanks for any tip

CrazyEnigma
9 Jul 2010, 11:42 AM
Are you using the EditorGridPanel? Those operations should already be performed for you.

Otherwise,
Might I suggest enclosing your updateRecord with a beginEdit() and endEdit(). This will help.

Reason: If you modified the record by field, how does the record know when to execute the update event without firing it every single time you updated a single field. That would be inefficient.

waken
11 Jul 2010, 10:54 PM
Thank's, but it's not a solution for me - "update" still not fireing :( Maybe it's complicated, becouse form is in another window (it's not grid editor).

All operations are fired by "Save" button on toolbar :




var rec = new oStore.recordType(panelAll.getForm().getValues());

if(Operation.state == 'dsInsert'){
oStore.insert(0, rec);
}else{
rec.beginEdit();
panelAll.getForm().updateRecord(rec);
rec.endEdit();
}

oStore.save();

Condor
11 Jul 2010, 11:28 PM
In your code 'rec' is always a NEW record, but for update it should be the current record in the store.

waken
11 Jul 2010, 11:36 PM
Ok, i found that in console when dumped record properties. How can i update record in store taking new values from form ?

// edit

I forgot what does it mean "pointer" - current selected/edited record should be parameter of updateRecord - not new created from form


var rec = grid.getSelectionModel().getSelected();
panelAll.getForm().updateRecord(rec);

</span></span>

Condor
11 Jul 2010, 11:49 PM
It seems, you answered your own question.