这条线grid.editRow(id, true);- 给出错误.
uncaught TypeError: Object #<Object> has no method 'editRow'
怎么解决这个问题?
<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', 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>
Run Code Online (Sandbox Code Playgroud)
您尚未发布您使用的整个HTML代码,因此我必须猜测.您描述的问题的最常见原因可能是以下两种情况之一:
$.jgrid.no_legacy_api = true;以前的代码jquery.jqGrid.min.js.因此,只能使用"新API".换句话说,您应该将代码替换grid.editRow(id, true)为代码grid.jqGrid('editRow', id, true).jquery.jqGrid.min.js不包含"内联编辑"模块的内容.要验证这一点,您可以jquery.jqGrid.min.js在文本编辑器中打开并grid.inlinedit.js在jquery.jqGrid.min.js文件开头的注释中搜索字符串.jquery.jqGrid.min.js文件中包含的所有jqGrid模块的列表位于文本"*Modules:"之后.您需要使用"内联编辑"模块下载jqGrid.| 归档时间: |
|
| 查看次数: |
4659 次 |
| 最近记录: |