处理非标准 ext js 网格服务器通信
我的 ext js (v4) 网格在任何给定时间都会接收 json 记录的集合,其中每个记录上都有一个标签,告诉网格要与其他属性一起执行的操作。例如,在传入的集合中,网格可能会遇到以下情况(以 id 为键):
{"records":
[{"id":"101", "name":"I'm new", "op":"create"},
{"id":"102", "name":"I'm old", "op":"delete"},
{"id":"103", "name":"I'm different", "op":"update"}]
}
我正在尝试编写代码来告诉网格或存储对模型执行这些不同的操作,但不这样做操作然后回发到服务器(毕竟,这就是指令的来源)。简而言之,客户端网格应该代表服务器上的内容,其中对象可以弹出或消失。
我已经研究了代理的读者和作者,或者从 json 代理本身继承并修改读/写行为,但似乎我仍然需要在模型本身上调用 destroy/create/update 命令然后以某种方式短路模型行为,这样他们就不会将该 CRUD 操作发送回服务器。然而,这些选项都感觉不太正确。
在这种情况下我应该使用 ext-js 组件而不是代理/读/写对象吗?
The ext js (v4) grid I have receives collections of json records at any given time, where each record has a tag on it that tells the grid the operation to perform alongside other attributes. For example, in an incoming collection a grid might encounter the following (with the id being the key):
{"records":
[{"id":"101", "name":"I'm new", "op":"create"},
{"id":"102", "name":"I'm old", "op":"delete"},
{"id":"103", "name":"I'm different", "op":"update"}]
}
I'm trying to write the code to tell the grid or store to perform these various operations on the models, but to not have that operation then post back to the server (after all, that's where the directive came from). Simply put the client grid should represent what's on the server, where the objects can be popping in and out of existence.
I've looked into the readers and writers for proxies, or inheriting from the json proxy itself and modifying the read/write behavior, but it seems as though I'd still need to call the destroy/create/update commands on the models themselves and then somehow short-circuit the model behavior so they don't send that crud operation back to the server. None of these options feel quite right, however.
Is there a ext-js component I should be using in this case instead of the proxy/read/write objects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你想多了。
您不需要将操作发送回网格。如果您的服务器发送一组新的数据,其中缺少记录(已删除),它将不会显示在网格中。如果您将更改的数据集发送到网格(写入),这些更改就会显示出来。如果您在服务器端添加记录并将该集发送到网格 - 将显示一条新记录。
基本上,如果您的服务器端驱动所有更改,那么您不需要编写器配置,而只需只读网格。
You are over thinking this.
You don't need to send operations back to the grid. If your server sends a new set of data with a missing record (deleted) it will not show up in the grid. If you send a changed data set to the grid (write) those changes will just show up. And if you add record on the server side and send the set to the grid - a new record will show.
Basically if your server side drives all of the changes then you don't need the writer config and just have the read only grid.