日期:2014-05-17  浏览次数:20336 次

JQgrid展示问题求教!
在mvc项目中使用JQGrid控件,在Controllers中写了如下方法:
C# code

        public JsonResult GetData()
        {
            var hh = new[]
            {
            new {id= "1", Name= "XXX", successCount= "2", totalCount= "3", ttl= "20", dataSize= "1"},
            new {id= "1", Name= "XXX", successCount= "2", totalCount= "3", ttl= "20", dataSize= "1"},
            new {id= "1", Name= "XXX", successCount= "2", totalCount= "3", ttl= "20", dataSize= "1"},
            new {id= "1", Name= "XXX", successCount= "2", totalCount= "3", ttl= "20", dataSize= "1"}
            };
            return Json(hh, JsonRequestBehavior.AllowGet);
        }


前台主要代码:
HTML code

    <script type="text/javascript">
        jQuery(document).ready(function () {
        jQuery("#jqList").jqGrid({
            url: '/Home/GetData',
            datatype: "json",
                        colNames: ['id', 'File Name', 'Successfully published', 'File-sets dropped', 'TTL(Min)', 'Data Size(MB)'],
                        colModel: [
                                { name: 'id', index: 'id', width: 100 },
                                { name: 'Name', index: 'Name', width: 200},
                                { name: 'successCount', index: 'successCount', width: 160},
                                { name: 'totalCount', index: 'totalCount', width: 120 },
                                { name: 'ttl', index: 'ttl', width: 120},
                                { name: 'dataSize', index: 'dataSize', width: 120}
                            ],

            pager: '#jqList',
            sortname: 'id',
            viewrecords: true,
            sortorder: "desc",
        }).navGrid("#jqList",{ edit: true, add: true, del: true });    
    })
    </script>


数据怎么也展示不出来,求指教

------解决方案--------------------
探讨
在mvc项目中使用JQGrid控件,在Controllers中写了如下方法:
C# code

public JsonResult GetData()
{
var hh = new[]
{
new {id= "1", Name= "XXX", successCount= "2", total……

------解决方案--------------------
加断点调试,看看最终 json 返回有值吗.
------解决方案--------------------
貌似返回的json格式不对的吧