jqGrid+Asp.Net MVC 和事务的主从细节

发布于 2024-08-17 01:06:39 字数 323 浏览 7 评论 0原文

我来自 delphi 世界,我想制作一个主/详细信息界面,例如订单和产品。
我已经采取行动使用字段和 jqGrid 显示数据。我想知道的是如何添加行、编辑或删除它们,但是,当用户确认主数据库中的更改时,只需在数据库中进行更改即可。
在delphi上,我将使用包含所有内存更改的TClientDataSet,并在确认后在事务中执行它们,例如:
开始
硕士.岗位
FOREACH 行 IN 行 Line.Post
犯罪

因此,在简历中,我不知道如何将网格中的行数组保留在内存中以及如何将它们发送回服务器进行提交。
任何帮助将不胜感激。提前致谢。

I'm coming from the delphi world and I want to make a master/detail interface, like Order and Products.
I already made actions to display the data using fields and a jqGrid. What I want know is how make possible to add lines, edit or remove them, but, just make the changes in db when the user confirm the changes in the master.
On delphi I would use a TClientDataSet with all the in memory changes and just after the confirmation would execute them inside a transaction like:
BEGIN
Master.Post
FOREACH Line IN Lines Line.Post
COMMIT

So in resume, I don't know how keep in memory the array of lines in the grid and how send them back to server to commit.
Any help will be appreciated. Thanks in Advance.

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

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

发布评论

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

评论(1

何以畏孤独 2024-08-24 01:06:39

您需要跟踪客户端的更改,也许使用网格中的一些隐藏字段和/或表单字段。当删除一行(之前存在于数据库中)时,您需要将其 id 添加到包含要删除的行的字段中。添加的行需要具有包含其数据的关联表单字段。当主服务器提交时,您将整个字段集汇总到 POST 中并将其发送回服务器。

使用 LINQ to SQL,您可以创建一个数据上下文,获取主对象,然后删除如此标记的相关对象(从 ids 的隐藏字段中),并创建/添加在获取主对象之前不存在的新相关对象。来自适当表单字段的值。然后,您将执行 SubmitChanges,所有语句都将在单个事务中执行。

You'll need to keep track of the changes client side, perhaps using some hidden fields and/or form fields in your grid. When a line is deleted (that previously existed in the db), you'll need to add it's id to a field containing lines to delete. Lines that are added need to have associated form fields containing their data. When the master is committed you roll the whole set of fields up into a POST and send that back to the server.

Using LINQ to SQL, you'd create a data context, get the master object, then delete the related objects (from the hidden field of ids) that are so marked and create/add new related objects that didn't exist before taking the values from the appropriate form fields. Then you'd do a SubmitChanges and all of the statements would be executed within a single transaction.

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