在 jqGrid 中,您可以一次内联编辑多行然后执行一次提交吗?

发布于 2024-11-06 08:49:26 字数 205 浏览 0 评论 0原文

我们使用 jqGrid 的 jQuery('#grid').editRow() 功能,它允许您内联编辑行中的字段。

jqGrid 是否支持一次内联编辑多行,我可以在多行上进行更改,然后一次提交所有行?

我们试图避免必须逐一对每一行进行更改,并对服务器进行单独的“往返”以每次提交,因为我们想要批量编辑多个记录的多个字段并有单个“提交”。

We are using the jQuery('#grid').editRow() feature of jqGrid, that allows you to edit fields in a row inline.

Does jqGrid support inline editing of multiple rows at once, where I can make changes on multiple rows and then submit all at once?

We are trying to avoid having to make changes to each row one by one and do a separate "round trip" to the server to commit each time, for cases were we want to bulk edit a number of fields for a number of records and have a single "commit".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

橘和柠 2024-11-13 08:49:26

jqGrid 没有实现多行的内联编辑。您可以使用本地编辑并将所有更改手动发布到服务器,但您必须自己实现所有更改的提交。

我个人不会在我的项目中实施这种行为。原因是我认为网站应该始终支持并发(乐观并发最有意义)。如果一个人尝试向服务器提交更改,服务器可能会回答并发错误:其他人已经修改了数据。在这种情况下,应刷新网格数据并重复行编辑。我发现在使用乐观并发的情况下实现多行编辑会出现问题。错误消息会是什么样子?如果更改了很多行,错误消息应该是什么样子?如果出现错误,用户应该怎么做?他/她应该重复完全更改数据吗?从用户的角度来看,好处在哪里?

在我拥有的所有 jqGrid 实现中,几乎立即提交一行编辑。所以我认为没有必要在项目中一次执行多行操作。发生并发错误时对用户来说的缺点比“往返”减少的优点更大。由于与服务器的连接非常好,因此在我的客户环境中发送数据不是问题。

Inline editing of multiple rows is not implemented by jqGrid. You can use local editing and post all the changes to the server manually, but you will have to implement the submit of all changes yourself.

I personally would not implement such behavior in my projects. The reason is that I think that the web site should always support concurrency (optimistic concurrency have the most sense). In the case if one person try to submit the changes to the server, the server can answer with the concurrency error: some other person have already modified the data. In the case the grid data should be refreshed and the editing of row should be repeated. I see problems with implementing of editing of multiple rows in case of the usage of optimistic concurrency. How would the error messages look like? If many rows are changed how the error message should look like? What should the user do in case of error? Should he/she repeat the full changing of the data? Where are the benefit from the users point of view?

The submitting of the editing of one row was almost immediately in all jqGrid implementations which I had. So I see no need to do multiple rows at once in the projects. Disadvantages for the user in case of concurrency errors are larger as advantages from "round trip" reduction. Because of very good connection to the server the sending of the data is not a problem in environments of my customers.

扬花落满肩 2024-11-13 08:49:26

在原始 JQGrid 实现中不可能内联编辑多行。原始实现的作用是,您编辑并失去焦点的每一行都将被提交。

相反,创建一个如下所示的自定义实现:
1. 覆盖(扩展)现有的 grid.inline.js 并编写您自己的编辑行并保存行。
2. 在编辑行功能中,配置添加单独收集的脏行(已编辑)。
3. 在保存行功能中,您可以只将脏行提交到服务器。

为了防止相同数据的并发更新,您可以通过以下方式之一拥有版本控制机制:
1. 所有行都有一个版本字段(隐藏)。当一行变脏时,增加版本字段。
2. 提交行时,检查现有版本号和新版本号。如果存在不匹配,请告知用户/更新现有的。 (这个,你可以很容易地实现)

就是这样!希望这有用! :-)

Inline editing of multiple rows is not possible in original JQGrid implementation. What the original implementation does is, every row which you edit and lose focus will be submitted.

Instead, create a custom implementation like this:
1. Override(Extend) the existing grid.inline.js and write your own edit rows and save rows.
2. In the edit rows function, configure in such a way as to add the dirty rows (edited) to be collected separately.
3. In the save rows function, you can submit only the dirty rows to the server.

And for preventing the concurrent updation of same data, you can have version control mechanism in either of the following ways:
1. Have a version field (hidden) for all the rows. When a row becomes dirty, increment the version field.
2. When submitting the rows, check for the version number existing and the new one. If there is a mismatch, intimate to the user/ update the existing. (This, you can implement quite easily)

That's it! Hope that was useful! :-)

梦里的微风 2024-11-13 08:49:26

我不太了解 jqGrid,但是我做了这个简单的测试(我可能会遗漏一些东西):

  1. 转到 jqGrid 演示页面 http://www.trirand.com/blog/jqgrid/jqgrid.html
  2. 加载道路编辑/基本示例页面。
  3. 手动运行此代码:

    jQuery("#rowed1").jqGrid('editRow', '11');
    jQuery("#rowed1").jqGrid('editRow', '12');
    jQuery("#rowed1").jqGrid('editRow', '13')
    
  4. 编辑三行

  5. 手动运行此代码:

    jQuery("#rowed1").jqGrid('saveRow', '11');
    jQuery("#rowed1").jqGrid('saveRow', '12');
    jQuery("#rowed1").jqGrid('saveRow', '13');
    

当然,url 参数是必需的,我认为您可以使用callback 选项来收集所有已编辑的行。

希望这有帮助

I don't know very much jqGrid, however I made this simple test (I might be missing something):

  1. Go to jqGrid demo page http://www.trirand.com/blog/jqgrid/jqgrid.html
  2. Load Road editing / Basic example page.
  3. Run this code manually:

    jQuery("#rowed1").jqGrid('editRow', '11');
    jQuery("#rowed1").jqGrid('editRow', '12');
    jQuery("#rowed1").jqGrid('editRow', '13')
    
  4. Edit the three rows

  5. Run this code manually:

    jQuery("#rowed1").jqGrid('saveRow', '11');
    jQuery("#rowed1").jqGrid('saveRow', '12');
    jQuery("#rowed1").jqGrid('saveRow', '13');
    

Of course the url parameter is required and I think you could use the callback option to gather all the edited rows.

Hope this helps

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