Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs. Can't catch write event after store.save() with create action

I'm trying to handle event after creating new record to ExtJS store and saving it to server. But I have a problem - write event firing only after update action. Documentation says:

@event write Fires if the server returns 200 after an Ext.data.Api.actions CRUD action. Success of the action is determined in the result['successProperty']property (NOTE for RESTful stores, a simple 20x response is sufficient for the actions "destroy" and "update". The "create" action should should return 200 along with a database pk).

Now I've such response from server: [{"tid": 5, "action": "CityGrid", "type": "rpc", "method": "create", "result": {"msg": "saved", "data": {}, }}]

I guess that adding a database.pk of created object to server response should resolve problem but I've no idea how to do it. I've tried this ... "data": {"Id":my_object.id} but with no effect.

like image 796
Shamanu4 Avatar asked Jan 01 '26 08:01

Shamanu4


1 Answers

This example: http://dev.sencha.com/deploy/dev/examples/writer/writer.html Creating return this:

{
    "success":true,
    "message":"Created record",
    "data": {"first":"sdfds","last":"sdfsdf","email":"[email protected]","id":10}
}

So just return store record for new object in Reader.root property.

like image 140
Kriplins Avatar answered Jan 06 '26 11:01

Kriplins



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!