jqGrid数据未获取

时间:2016-03-31 07:49:39

标签: entity-framework jqgrid

我的jqGrid有这个代码。但是这些数据并没有在网格中显示。空网格正在显示。我使用过实体框架。

控制器代码

public ActionResult GetJqGridData(string page, string rows, string sidx, string sord)
    {
        var jqGridData = new JqGridObject()
        {
            Data =GetSomeSampleData(),
            Page = page,
            PageSize = 3, 
            SortColumn = sidx,
            SortOrder = sord
        };
        return Json(jqGridData, JsonRequestBehavior.AllowGet);
    }

    public List<employee> GetSomeSampleData()
    {
        var item =(from t in db.employees select t) ;
        List<employee> s = (from r in item where r.companyID == 2 select r).ToList();
        return s;
    }

我的jqGrid代码是

$(document).ready(function() {  
$("#myGrid").jqGrid({  
    url:'@Url.Action("GetJqGridData")',  
    datatype:'json',  
    myType:'GET',  
    colNames:['employeeID', 'employeeName','salary','companyID'],  
    colModel:[  
        { name: 'employeeID', index: 'employeeID'},  
        { name: 'employeeName', index: 'employeeName' },
         { name: 'salary', index: 'salary' },
          { name: 'companyID', index: 'companyID'}  
    ],  
    jsonReader: {  
        root: 'Data',  
        id: 'id',  
        repeatitems: false  
    },  
    pager: $('#myPager'),  
    rowNum:5,  
    rowList: [2, 5, 10],  
    width:600,  
    viewrecords:true,  
    caption: 'Jqgrid MVC Tutorial'  
});  
});

我正在使用空白数据获取jqGrid。请帮我 提前谢谢

0 个答案:

没有答案