MVC 与 Jquery ajax 删除以及如何在查询字符串中保留分页和其他过滤器?
我有一个搜索页面,其中包含一个下拉列表框、一个按钮和一个搜索结果部分视图。当用户点击按钮时,它将使用 get 请求来分页过滤数据。对于表格数据,最后一列是“删除”链接,当前删除功能通过使用 jquery ajax post 可以正常工作,但我只是无法正确刷新数据。原因是我需要当前的搜索 url(或查询字符串,如过滤器值和寻呼号码)参数来保持用户选择相同。我怎样才能做到这一点?
谢谢
这是我的默认操作有两个参数
public ActionResult Default(string state, int? page = 1)
{
const int pageSize = 10;
SearchModel model = new SearchModel();
int total;
List<xxx> result = _repo.SearchByState(state, page.Value, pageSize, out total);
model.PageInfo = Pagination.ToPagedList<xxx>(result, page.Value, pageSize, total, 10);
model.State = state;
model.TotalCount = total;
return View(model);
}
I am having a search page with one dropdown list box, one button and one search result partial view. when user clicks button, it will use get request to filter the data with paging. for the tabular data the last column is "delete" link, currently delete functionality is working fine by using jquery ajax post, but I just can't refreh the data correctly. The reason for that is I need current search url ( or querystring like filter value & paging number)parameter to keep the user selection same. How can I achieve that?
Thanks
Here is my Default Action with two parameter
public ActionResult Default(string state, int? page = 1)
{
const int pageSize = 10;
SearchModel model = new SearchModel();
int total;
List<xxx> result = _repo.SearchByState(state, page.Value, pageSize, out total);
model.PageInfo = Pagination.ToPagedList<xxx>(result, page.Value, pageSize, total, 10);
model.State = state;
model.TotalCount = total;
return View(model);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我过去所做的就是保持过滤/搜索条件的实例处于活动状态并根据需要传递它。在这种情况下,我主要使用 AJAX 调用来获取和设置数据。因此,JavaScript 中的条件对象可能如下所示(默认情况下):
然后,在 AJAXy Delete 调用成功回调时,调用 Get/LoadData 并传递条件对象。
What I've done in the past is keep an instance of my filter/search criteria alive and pass it around as needed. In that scenario I used mostly AJAX calls to get and set data. So your criteria object in JavaScript may look like this (by default):
Then on a successful callback from your AJAXy Delete call, call Get/LoadData and pass the criteria object along.