开发者

jQuery Grid error

I'm 开发者_如何学JAVAtrying to use the jQuery grid. I keep getting this error at the jquery-1.5.1.js file. Microsoft JScript runtime error: Object doesn't support this property or method

I'm just trying to run the code I found here http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx as a test

I have this in the controller:

    public JsonResult GridData(string sidx, string sord, int page, int rows)
    {
        int totalPages = 1; // we'll implement later
        int pageSize = rows;
        int totalRecords = 3; // implement later

        var jsonData = new
        {
            total = totalPages,
            page = page,
            records = totalRecords,
            rows = new[]{
                new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}},
                new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}},
                new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}}
            }
        };
        return Json(jsonData);
    }

and in my Index.cshtml I have the following

<script type="text/javascript">
        jQuery(document).ready(function () {
            jQuery("#list").jqGrid({
                url: '/Home/GridData/',
                datatype: 'json',
                mtype: 'POST',
                colNames: ['Id', 'Votes', 'Title'],
                colModel: [
      { name: 'Id', index: 'Id', width: 40, align: 'left' },
      { name: 'Votes', index: 'Votes', width: 40, align: 'left' },
      { name: 'Title', index: 'Title', width: 400, align: 'left'}],
                pager: jQuery('#pager'),
                rowNum: 10,
                rowList: [5, 10, 20, 50],
                sortname: 'Id',
                sortorder: "desc",
                viewrecords: true,
                imgpath: '',
                caption: 'My first grid'
            });
        }); 
</script>  

Can somebody guide me what I'm doing wrong please? I have the latest version of jqGrid from trirand.com and have copied all the files into the Script directory of my MVC3 project.

Thank you for any help you can provide.


As suggested by Oleg in the comments, the open source version of jqGrid is the prerequisite for most of the examples you will find around for use of jqGrid with ASP.Net MVC :

  • original Phil Haack article.
  • Tim Davies MVC 3 version (with some naming issues)
  • Oleg's answer to a previous question, which expands on the two previous articles
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜