外部。使用创建操作无法捕获 store.save() 之后的写入事件

发布于 2024-10-08 03:07:57 字数 558 浏览 0 评论 0原文

我正在尝试在向 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请帮我爱他 2024-10-15 03:07:57

此示例: http://dev.sencha.com/deploy/dev/示例/writer/writer.html
创建返回此:

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

因此只需在 Reader.root 属性中返回新对象的存储记录。

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.

心的憧憬 2024-10-15 03:07:57

尝试将 JsonReader 的 idProperty 设置为 PK 的名称。另外,我认为 data: 应该是一个数组
“数据”:[{“id”:....}]
但我可能错了:P

Try setting idProperty of your JsonReader to the name of your PK. Also, I think that data: should be an array
"data": [{"id": ....}]
but I might be wrong :P

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文