更新 Asp.Net MVC 中的表
我在页面上有表 [HTML 表],我想从表中删除记录,并在删除记录后更新表。
<%= Ajax.ActionLink("Delete Ajax", "PostTypeDelete",new { id = item.int_PostTypeId },
new AjaxOptions{LoadingElementId="status"}) %>
我使用上面的代码,它工作正常(它删除记录),但它不更新表。
I have table [HTML Table] on page I want to delete record from table and also update table after deletion record.
<%= Ajax.ActionLink("Delete Ajax", "PostTypeDelete",new { id = item.int_PostTypeId },
new AjaxOptions{LoadingElementId="status"}) %>
I used above code its working fine (it delete record) but it doesn't update table.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该操作需要返回表的新副本减去已删除的行,并且您需要将表的 id 作为 AjaxOptions 的一部分提供给扩展方法 (UpdateTargetId) 因此它知道要使用操作的响应替换哪个元素。
或者 - 如果始终呈现整个表,即,由于当前行被删除,您将永远不会出现新行 - 您可以省略返回表并拥有一个完成的处理程序,该处理程序只需从表中删除有问题的行。在这种情况下,您可能只想返回一个与当前行具有相同 id 的空行,并在操作返回时使用处理程序将其删除。
The action needs to return a new copy of the table minus the deleted row and you need to give the id of the table to the extension method as part of the AjaxOptions (UpdateTargetId) so it knows which element to replace with the response from the action.
Alternatively -- if the entire table is always rendered, i.e., you will never have new rows appearing due to the current row being deleted -- you can omit returning the table and have a completed handler that simply removes the row in question from the table. In that case you might want to return just an empty row with the same id as the current row and use a handler to remove it when the action returns.