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:
- You included code like
$.jgrid.no_legacy_api = true;
beforejquery.jqGrid.min.js
. So only "new API" can be used. In other words you should replace the codegrid.editRow(id, true)
to the codegrid.jqGrid('editRow', id, true)
. - You downloaded and used
jquery.jqGrid.min.js
which doesn't include the "Inline Editing" module. To verify this you can openjquery.jqGrid.min.js
in a text editor and search forgrid.inlinedit.js
string in the comment which is at the begining ofjquery.jqGrid.min.js
file. The list of all jqGrid modules included in thejquery.jqGrid.min.js
file is after the text "* Modules: ". You need to download jqGrid with "Inline Editing" module.
精彩评论