开发者

Unable to use editRow with jqgrid

The line grid.editRow(id, true); - is giving error.

uncaught TypeError: Object #<Object> has no method 'editRow'

How can this be fixed?

<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', editable: true, edittype: 'text' },
      { name: 'Title', index: 'Title开发者_如何学Python', width: 400, align: 'left'}],
            pager: jQuery('#pager'),
            rowNum: 10,
            rowList: [10, 20, 50],
            sortname: 'Id',
            sortorder: "desc",
            viewrecords: true,
            imgpath: '',
            caption: 'My first grid',
            onSelectRow: function (id) {
                var grid = $("#list");                    
                grid.editRow(id, true);
            }
        });
    }); 
</script>  
...
<table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>


You haven't posted the whole HTML code which you use, so I'll have to guess. The most common reason for the problem which you describe could be one of these two:

  1. You included code like $.jgrid.no_legacy_api = true; before jquery.jqGrid.min.js. So only "new API" can be used. In other words you should replace the code grid.editRow(id, true) to the code grid.jqGrid('editRow', id, true).
  2. You downloaded and used jquery.jqGrid.min.js which doesn't include the "Inline Editing" module. To verify this you can open jquery.jqGrid.min.js in a text editor and search for grid.inlinedit.js string in the comment which is at the begining of jquery.jqGrid.min.js file. The list of all jqGrid modules included in the jquery.jqGrid.min.js file is after the text "* Modules: ". You need to download jqGrid with "Inline Editing" module.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜