在SlickGrid中保存更改

编程入门 行业动态 更新时间:2024-10-09 19:21:24
本文介绍了在SlickGrid中保存更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

HI,我在看SlickGrid,我可以看到如何编辑单元格的示例,但是是否保存这些更改。我还没有找到一个例子,告诉我如何做到这一点。

I'm looking at SlickGrid and I can see example on how to edit the cell, however do I save these changes. I have yet to find an example that tells me how to do this.

推荐答案

保存SlickGrid的窍门是实现该网格将更新您在编辑单元格时创建网格时提供的数据数组。

The trick to saving the SlickGrid is to realise that the grid will update the array of data that you supplied when creating the grid as the cells are edited.

然后我保存的方式是在表单中包含一个提交按钮和网格下方的隐藏字段。我将提交事件进行陷阱并使用 JSON插件串行化该数组并将其放置在隐藏字段中。在服务器端,您将收到一个JSON字符串,您可以反序列化,循环并写入数据库。

The way I then save that is to include a form with a submit button and a hidden field below the grid. I trap the submit event and use the JSON plugin to serialise the array and place it in the hidden field. On the server side you'll receive a JSON string which you can deserialise, loop through and write to the database.

假设您的数据数组被称为data样品,以下应该适合你:

Assuming your array of data is called "data" like the samples, the following should work for you:

<form action="?" method="POST"> <input type="submit" value="Save"> <input type="hidden" name="data" value=""> </form> <script> $(function() { $("form").submit( function() { $("input[name='data']").val($.JSON.encode(data)); } ); }); </script>

更多推荐

在SlickGrid中保存更改

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

发布评论

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

>www.elefans.com

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