I was also facing the same issue like lost of original URL for Sorting and paging for WebGrid Control in MVC.I did some custom solution.
Please find it here .This is in JQuery.Please let me know for any query.
For first time on page load i am Storing Original URL in Hidden.
function SetHref()
{
$('#checkableGrid').find('a').each(function () {
var URL = this.href.split('?')[0]
var hiddenhrefval = $("#hiddenhref").val();
if(URL != "" && URL != undefined)
{
if (hiddenhrefval == "") {
$("#hiddenhref").val(URL);
}
}
});
}
This is Calling on Document.ready
Now On every change of Action or calling some different method i am getting Original URL from Hidden and setting it back to original URL.
function GetHref()
{
$('#checkableGrid').find('a').each(function () {
var URLArray = this.href.split('?')
var URLWithoutQryString = URLArray[0];
var URLQryString= URLArray[1];
var hiddenhrefval = $("#hiddenhref").val();
if (URLWithoutQryString != hiddenhrefval)
{
var CompleteURL = hiddenhrefval + "?" + URLQryString;
$(this).attr("href", CompleteURL);
}
});
}
function ChangeStatus() {
$("#CRFStatus").on("change", function () {
var CRFStatusID = $("#CRFStatus").val();
if (CRFStatusID != "") {
RenderCRFQueueItemsList(CRFStatusID);
GetHref();
}
else
{
$('#CRFStatus option:contains("--Select Status--")').prop('selected', true);
}
});
}
This would set all anchor href to original.