I am using the webgrid so i can display data from my database. On page load the grid is displaying correctly on the page, but when i try to filter the data, i have a textbox and a submit button, when i press on the search button i get an error : “a jquery script reference is required in order to enable ajax support in the webgrid helper”. I cant seem to find were the problem is.
this is my grid in my view,
Hello,
I am using the webgrid so i can display data from my database. On page load the grid is displaying correctly on the page, but when i try to filter the data, i have a textbox and a submit button, when i press on the search button i get an error : “a jquery script reference is required in order to enable ajax support in the webgrid helper”. I cant seem to find were the problem is.
this is my grid in my view,
<div id="myGrid">
@Html.Partial("Grids/_gridPayments", Model)
</div>
this is my partial webgrid view
@model IEnumerable<DAS.DAL.CustomerPayment>
@{
var grid = new WebGrid(source: Model, rowsPerPage: 15, ajaxUpdateContainerId: "myGrid");
@grid.GetHtml(rowStyle: "gridRow", alternatingRowStyle: "gridAltRow", footerStyle: "gridFooter", columns: grid.Columns(
grid.Column("FullName", "Πελάτης"),
grid.Column("Amount", "Ποσό", format: (item) => string.Format("{0:C}", item.Amount)),
grid.Column("Descr", "Περιγραφή"),
grid.Column("DTPaid", "Ημερομηνία πληρωμής", format: (item) => string.Format("{0:dd-MMM-yyyy}", item.DTPaid))
));
}
and finally my controller function is
var payments = BLPayments.getAllPayments();
if (!string.IsNullOrEmpty(txtSearchCustomer))
payments = payments.Where(a => a.FullName.Contains(txtSearchCustomer)).ToList();
if (!string.IsNullOrEmpty(txtSearchFromDate) && !string.IsNullOrEmpty(txtSearchToDate))
payments = payments.Where(a => a.DTPaid >= DateTime.ParseExact(txtSearchFromDate, "MM/dd/yyyy", null) && a.DTPaid <= DateTime.ParseExact(txtSearchToDate, "MM/dd/yyyy", null)).ToList();
if (!string.IsNullOrEmpty(txtSearchFromDate) && string.IsNullOrEmpty(txtSearchToDate))
payments = payments.Where(a => a.DTPaid >= DateTime.ParseExact(txtSearchFromDate, "MM/dd/yyyy", null)).ToList();
if (string.IsNullOrEmpty(txtSearchFromDate) && !string.IsNullOrEmpty(txtSearchToDate))
payments = payments.Where(a => a.DTPaid <= DateTime.ParseExact(txtSearchToDate, "MM/dd/yyyy", null)).ToList();
return PartialView("Grids/_gridPayments", payments);
thanks in advance.
Added this code
if (Request.IsAjaxRequest())
return PartialView("Grids/_gridPremadeMeals", premadeMeals);
else
return View("ViewPremadeMeals", premadeMeals);
and worked. I think it was refreshing the whole page, but still cant find why..