具有同步功能的rowedit网格

编程入门 行业动态 更新时间:2024-10-17 19:22:48
本文介绍了具有同步功能的rowedit网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试实现一个通用的行编辑网格,例如此例子,不同之处在于我想将更改与服务器后端同步.到目前为止,我可以使用onRoweditAdd添加新行.

I try to implement a general rowediting grid like this example, with the difference that I would like to sync the changes with the server backend. Until now, I can add a new line with onRoweditAdd.

Ext.define('Mb.view.base.RoweditListController', { extend: 'Ext.app.ViewController', alias: 'controller.roweditlist', onRoweditAdd: function(me){ var grid = me.up('panel'), edit = grid.editingPlugin, store = grid.getStore(), record = store.getModel().create({id: 0}); edit.cancelEdit() store.insert(0, record) edit.startEdit(record, 0) }, editRowedit: function(editor, ctx) { var store = ctx.grid.getStore(); store.sync() } })

问题是store.sync()不会将create请求发送到服务器,而是发送update请求.似乎没有考虑store.insert(0, record).仅同步用户所做的修改.罪魁祸首是什么?

The problem is that store.sync() does not send a create request to the server, but an update request. It looks like store.insert(0, record) is not accounted for. Only the modification done by the user is synched. What could be the culprit ?

推荐答案

通过在记录中提供现有的id,ExtJS假定此记录已存在于您的商店中并且必须进行更新.如果您不提供ID,则它假定它是新创建的记录,并且将遵循创建路线.这是基于这样的假设:您使用生成的ID策略(通常应该这样做),因此您永远不会在创建时自己提供ID.

By giving an existing id in a record, ExtJS assumes this record already exist in your store and has to be updated. If you don't give an id then it supposes it is a newly created record and will go the create route. This comes from the assumption that you use a generated ID strategy (which you generally should) and thus you would never provide IDs yourself upon creation.

在后台,ExtJS将记录标记为幻像:true或false.虚拟记录是仅存在于前端且尚未持久的记录.创建没有id的记录会将其标记为幻像,而创建具有已提供的ID的记录不会将其标记为幻像,也不会触发创建调用,而是会触发更新

Under the hood, ExtJS marks the record as phantom: true or false. Phantom records are the ones that only exist in the front end and haven't been persisted yet. Creating a record with no id will mark it as phantom whereas creating a record with an id already provided will not mark it as phantom and will not trigger a create call but an update instead

更多推荐

具有同步功能的rowedit网格

本文发布于:2023-11-11 05:49:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577553.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   功能   rowedit

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!