I try to filter jQgrid data with a date field. Please see my below image.
There is a two text boxes and a button in my webpage. I try to filter the customer data
in between the selected date range. I call my setGridParam inside the button click event.
Please see my HTML below.
$("#Button1").click(function () {
var fromdate = $("#txtFrom").val();
var todate = $("#txtTo").val();
jQuery("#jQGridDemo").jqGrid('setGridParam', {
url: "/Home/GetFilterData?sidx=" + fromdate + "&sord=" + todate, page: 1
}).trigger("reloadGrid");
});
And this is my controller action
[HttpPost]
public JsonResult GetFilterData(string sidx, string sord)
{
using (jQGridDemoEntities db = new jQGridDemoEntities())
{
var customers = new List<Customer>();
customers = db.Customers.ToList();
return Json((
from customer in customers
orderby customer.Id descending
select new[]{
customer.Id.ToString(CultureInfo.InvariantCulture),
customer.FirstName,
customer.LastName,
customer.IsMale.ToString(),
customer.Address,
customer.Email,
customer.Phone,
customer.Country.Name,
customer.Note,
customer.Created.ToString()
}).ToArray(), JsonRequestBehavior.AllowGet);
}
}
I call this function in SetGridParam function but this action is not fired.