ASP.NET MVC 2.0 Implementation of searching in jqgrid

后端 未结 4 800
轻奢々
轻奢々 2020-11-21 07:21

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

4条回答
  •  既然无缘
    2020-11-21 07:55

    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); }

提交回复
热议问题