I have implemented the webgrid using the below article
Data is loading in grid, but Header with Filter is not getting added. Because on load of this page getting 2 Javascript errors.
1. 0x800a1391 - javascript runtime error 'jquery' is undefined
2. 0x800a1391 - JavaScript runtime error: '$' is undefined Kindly check my code and correct me, where I am doing wrong.
@{
ViewBag.Title = "REDFLoggerDetails";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@model IEnumerable<REDF_DataContracts.RequestResponse>
<h2>REDFLoggerDetails</h2>
@{
WebGrid webGrid = new WebGrid(source: Model, canPage: true, canSort: true);
}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="~/Scripts/quicksearch.js"></script>
@webGrid.GetHtml(
htmlAttributes: new { @id = "WebGrid", @class = "Grid" },
columns: webGrid.Columns(
webGrid.Column("ServiceType", "Service Name"),
webGrid.Column("NID", "Legal ID"),
webGrid.Column("ResponseCodeValue", "Response Code"),
webGrid.Column("ResponseResult", "Response Result"),
webGrid.Column("UserID", "User Name"),
webGrid.Column("CreatedDate", "Date")))
@*<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="/Scripts/quicksearch.js"></script>*@
<script type="text/javascript">
$(function () {
//Add Header Row with TextBoxes.
var row = $("<TR />");
$("#WebGrid TR").eq(0).find("TH").each(function () {
row.append("<th><input type = 'text' /></th>");
});
$("#WebGrid TR").eq(0).after(row);
//Applying the QuickSearch Plugin to each TextBox.
$("#WebGrid TR").eq(1).find("INPUT").each(function (i) {
$(this).quicksearch("#WebGrid tr:not(:has(th))", {
'testQuery': function (query, txt, row) {
return $(row).children(":eq(" + i + ")").text().toLowerCase().indexOf(query[0].toLowerCase()) != -1;
}
});
});
});
</script>