Extjs. Unable to catch write event after store.save () with create action

I am trying to handle an event after creating a new record in ExtJS repository and saving it on the server. But I have a problem - the event recording is triggered only after the update action. The documentation reads:

@event write Fires if the server returns 200 after the Ext.data.Api.actions CRUD action. The success of the action is defined in the result property ['successProperty'] (NOTE for RESTful stores, a simple 20x response is enough for the destroy and update actions. The β€œcreate” action should return 200 with the pk database).

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

I assume that adding the .pk database of the created object to the server response should fix the problem, but I don't know how to do it. I tried this one ... "data": {"Id":my_object.id}, but with no effect.

+3
source share
2 answers

In 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":"asd@sdfs.sd","id":10}
}

So just return the storage entry for the new object in the Reader.root property.

+2
source

Try installing idPropertyyour JsonReader in the name of your PC. Also, I think it data:should be an array "data": [{"id": ....}] but I could be wrong: P

+1
source

Source: https://habr.com/ru/post/1781212/


All Articles