1

I'm trying 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.

SimpleUser
  • 1,341
  • 2
  • 16
  • 36
  • Look at UPDATED part of [the answer](http://stackoverflow.com/questions/5500805/asp-net-mvc-2-0-implementation-of-searching-in-jqgrid/5501644#5501644). It contains modification of the example which you use. – Oleg Jul 02 '11 at 06:42
  • Hi Oleg, thank you for your reply. I found this demo on the jqGrid site http://www.trirand.net/forum/default.aspx?g=posts&t=917 and downloaded the demo. It gives me a similar error too. Could it be an issue with my version of jqGrid or jQuery? I did try to reinstall both through NuGet, but it still displays the error, but now atleast it is showing me the grid when I click Continue on the error – SimpleUser Jul 02 '11 at 10:06
  • 1
    The project which you downloaded from http://www.trirand.net/forum/default.aspx?g=posts&t=917 use **commercial** version of jqGrid. [The project](http://www.ok-soft-gmbh.com/jqGrid/jqGridDemo.zip) from [the answer](http://stackoverflow.com/questions/5500805/asp-net-mvc-2-0-implementation-of-searching-in-jqgrid/5501644#5501644) is absolutely another example. It uses **free open source** version of jqGrid which you can download from [here](http://www.trirand.com/blog/?page_id=6). Phil Haack which example you used are also based on free open source version of jqGrid. What version you want to use? – Oleg Jul 02 '11 at 15:44
  • Ideally the free version! I actually didn't know you got a free version of jqGrid. I'll have a look at the link you posted, thanks. – SimpleUser Jul 03 '11 at 09:33

1 Answers1

0

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 :

Community
  • 1
  • 1
Matthieu
  • 4,605
  • 4
  • 40
  • 60