Hi I am trying to use the single column search in jqgrid using MVC 2 IN .NET (VS 2008) this is the code I have so far but I need an example to match it with or a tip of wha
I have made an attempt with search argument that did not succeed
public ActionResult DynamicGridData(string sidx, string sord, int page, int rows)
{
var context = new AlertsManagementDataContext();
int pageIndex = Convert.ToInt32(page) - 1;
int pageSize = rows;
int totalRecords = context.Alerts.Count();
int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
IQueryable alerts = null;
try
{
//if (!search)
// {
alerts = context.Alerts.
OrderBy(sidx + " " + sord).
Skip(pageIndex * pageSize).
Take(pageSize);
// }
//else
// {
// alerts = context.Alerts.Where (fieldname +"='"+ fieldvalue +"'").
// Skip(pageIndex * pageSize).
// Take(pageSize);
// }
}
catch (ParseException ex)
{
Response.Write(ex.Position + " " + ex.Message + " " + ex.Data.ToString());
}
//var alerts =
// from a in context.Alerts
// orderby sidx ascending
// select a;
var jsonData = new {
total = totalPages,
page = page,
records = totalRecords,
rows = ( from alert in alerts
select new {
id = alert.AlertId,
cell = new string[] {
"Edit " +"|"+ "Detail ",
alert.AlertId.ToString() ,
alert.Policy.Name ,
alert.PolicyRule ,
alert.AlertStatus.Status ,
alert.Code.ToString() ,
alert.Message ,
alert.Category.Name}
}).ToArray()
};
return Json(jsonData); }