Note that there are some explanatory texts on larger screens.

plurals
  1. PORefreshing a MVC3 / MVC4 WebGrid without losing current page / filter
    primarykey
    data
    text
    <p>I have a WebGrid bound to a Plain Class Object. Nothing Fancy. The Grid features some paging and is used to display a list of users. The Last column of the Grid is an Ajax Action Link which fires a Pop Up DIV with some Edit Controls. On completion of this Edit the OnSuccess Event fires and closes the DIV. This is where I would like to now refresh the grid without losing the current page/search/filter applied. One way that comes to mind is to somehow grab the WebGrids Url and then refreshing it with JQuery, however.. I cant find a way to retrieve the current url and parameters? Anyone tried this before?</p> <h2>UPDATE: Thanks to the answers this is what I have resorted to now:)</h2> <p>The ActionResult called by the ajax edit</p> <pre><code>[HttpPost] public ActionResult EditUserDetails(User model) { if (ModelState.IsValid) { // for the sake of brevity. // do your edit logic here and then on success you return: return Json(new { state = "success", id = "1", name = "John", surname = "Doe", etc = "blah" }); } else { return Json(new { state = "failed", message="some error text here maybe?" }); } } </code></pre> <p>Then on the edit click I set the class of the row to be .editRowSelected. (i will be changing this to an id rather)</p> <p>Then onSuccess of the Ajax Update Call:</p> <pre><code>function onSuccess(ajaxContext) { var result = eval(ajaxContext); if (result.state == "Success") { var row = $('.busyEditRow'); row.html(content); $('.busyEditRow').removeClass('busyEditRow'); } else { // Display some error stuffs here with the message - result.message } } </code></pre> <p>This updates the grid row with the new data:)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload