外部。使用创建操作无法捕获 store.save() 之后的写入事件
我正在尝试在向 ExtJS 存储创建新记录并将其保存到服务器后处理事件。但我有一个问题 - 仅在更新操作后写入事件触发。文档说:
@event write 如果服务器 后返回 200 Ext.data.Api.actions CRUD 操作。 行动的成功取决于 结果['successProperty']属性 (注意,对于 RESTful 商店,简单的 20x 响应对于行动来说是足够的 “销毁”和“更新”。那个“创造” 操作应该返回 200 与数据库pk)。
现在我从服务器得到这样的响应: [{"tid": 5, "action": "CityGrid", "type": "rpc", "method": "create", "result": {" msg": "saved", "data": {}, }}]
我想将创建的对象的database.pk添加到服务器响应应该可以解决问题,但我不知道该怎么做。我已经尝试过这个 ... "data": {"Id":my_object.id}
但没有效果。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此示例: http://dev.sencha.com/deploy/dev/示例/writer/writer.html
创建返回此:
因此只需在 Reader.root 属性中返回新对象的存储记录。
This example: http://dev.sencha.com/deploy/dev/examples/writer/writer.html
Creating return this:
So just return store record for new object in Reader.root property.
尝试将 JsonReader 的 idProperty 设置为 PK 的名称。另外,我认为
data:
应该是一个数组“数据”:[{“id”:....}]
但我可能错了:P
Try setting
idProperty
of your JsonReader to the name of your PK. Also, I think thatdata:
should be an array"data": [{"id": ....}]
but I might be wrong :P