|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcGrid.Models.Grid
{
public class GridModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
try
{
var request = controllerContext.HttpContext.Request;
return new GridSettings
{
IsSearch = bool.Parse(request["_search"] ?? "false"),
PageIndex = int.Parse(request["page"] ?? "1"),
PageSize = int.Parse(request["rows"] ?? "10"),
SortColumn = request["sidx"] ?? "",
SortOrder = request["sord"] ?? "asc",
Where = Filter.Create(request["filters"] ?? "")
};
}
catch
{
return null;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Interested in design/development of framework functionality using the best patterns and practices.