asp.net mvc 2 jqgrid添加记录 [英] asp.net mvc 2 jqgrid add record

查看:119
本文介绍了asp.net mvc 2 jqgrid添加记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在jqgrid中显示添加新记录"显示,但是它没有显示出来?

i am trying to display the 'add new record' display in jqgrid but it does not show up?

  <script type="text/javascript">
    jQuery(document).ready(function () {

        $("#addBtn").click(function () {
            $("#list").jqGrid('editGridRow', "new", { height: 280, reloadAfterSubmit: false });
        });


      var lastsel;
      $("#list").jqGrid({
          url: '/Home/DynamicGridData/',
          datatype: 'json',
          mtype: 'GET',
          colNames: ['IdNr', 'Id', 'FirstName', 'LastName'],
          colModel: [
      { name: 'IdNr', index: 'IdNr', width: 40, align: 'left',
          editable: true, editrules: { edithidden: true }, hidden: true
      },
      { name: 'Id', index: 'Id', width: 40, align: 'left',
          editable: false
      },
      { name: 'FirstName', index: 'FirstName', width: 200, align: 'left', editable: true, edittype: 'text', editoptions: { size: 20, maxlength: 30} },
      { name: 'LastName', index: 'LastName', width: 300, align: 'left', editable: true, edittype: 'text', editoptions: { size: 20, maxlength: 30}}],
          onSelectRow: function (id) {
              if (id && id !== lastsel) {
                  jQuery('#list').restoreRow(lastsel);
                  jQuery('#list').editRow(id, true);
                  jQuery("#grid_id").editGridRow(id, options); 
                    lastsel = id;
              }
          },
          editurl: "/Home/GridSave",
          pager: jQuery('#pager'),
          rowNum: 10,
          rowList: [5, 10, 20, 50],
          sortname: 'Id',
          sortorder: "desc",
          viewrecords: true,
          imgpath: '/content/themes/steel/images',
          caption: 'Employees'
      });



  });



</script>  


<table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>

推荐答案

如何查看

How you can see here the code which you posted in general work.

我想您在 jqGrid的下载.在打开使用的jquery.jqGrid.min.js文件时,您可以在文件开头之后检查注释行.您应该在列表中找到以下内容:" Modules:"之后的grid.base.jsgrid.common.jsgrid.formedit.js.我建议您始终还包括"Formatter"模块.常见规则是:最好也包括许多模块太少了.

I suppose that you don't included "Form Edit" module or "Common" module during downloading of the jqGrid. In you open jquery.jqGrid.min.js file which you use you can examine the comment line after the beginning of the file. You should find at list the following: grid.base.js, grid.common.js and grid.formedit.js after "Modules:. I recommend you always include "Formatter" module also. The common rule is: better include too many modules as too few.

其他小注释:长时间以来您不应该使用已弃用参数imgpath.还可以发出默认参数,例如align: 'left'editable: false. HTML代码中的<table>定义可以简化为<table id="list"></table>.

Small additional remarks: You should not use since a long time deprecated parameter imgpath. Default parameters like align: 'left' or editable: false can be also emitted. The <table> definition in the HTML code can be reduced to <table id="list"></table>.

这篇关于asp.net mvc 2 jqgrid添加记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆