开发者

MVC with Jquery ajax delete and how to keep the paging and other filter in the querystring?

开发者 https://www.devze.com 2023-03-10 03:37 出处:网络
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 da

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.SearchB开发者_运维技巧yState(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);
    }


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):

var criteria = {
  name : {}, 
  title : {}, 
  pageSize : 10, 
  currentPage : 1
};

Then on a successful callback from your AJAXy Delete call, call Get/LoadData and pass the criteria object along.

0

精彩评论

暂无评论...
验证码 换一张
取 消