如何在JqGrid中添加新记录?

时间:2011-05-31 09:04:13

标签: jquery jqgrid

这是我的代码,当我点击添加记录然后弹出新窗口但不显示任何记录。 我是不是

                      PHP jqGrid

    <link rel="stylesheet" type="text/css" media="screen" href="themes/redmond/jquery-ui-1.8.2.custom.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="themes/ui.jqgrid.css" />

    <script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
    <script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
//这里我们设置一个全局的altRows选项 jQuery.extend(jQuery.jgrid.defaults,{altRows:true});
    <script type="text/javascript">

        jQuery(document).ready(function(){
        jQuery("#jsonmap").jqGrid({
                url:'example.php?q=4',
                datatype: "json",
                colNames:['Inv No','invdate', 'Client', 'Amount','Tax','Total','Notes'],
                colModel:[
                    {name:'id',index:'id', width:55},
                    {name:'invdate',index:'invdate', width:90, jsonmap:"invdate"},
                    {name:'name',index:'name asc, invdate', width:100},
                    {name:'amount',index:'amount', width:80, align:"right"},
                    {name:'tax',index:'tax', width:80, align:"right"},
                    {name:'total',index:'total', width:80,align:"right"},
                    {name:'note',index:'note', width:150, sortable:false}
                ],
                rowNum:10,
                rowList:[10,20,30],
                pager: '#pjmap',
                sortname: 'id',
                viewrecords: true,
                sortorder: "desc",
                editurl:'edit.php',
                jsonReader: {
                    repeatitems : false,
                    id: "0"
                },
                caption: "JSON Mapping",
                height: '100%'
            }).navGrid('#pjmap',"new",{height:280,reloadAfterSubmit:false}); 

        });
    </script>

</head>
<body>
    <table id="jsonmap"></table>
    <div id="pjmap"></div>

</body>

1 个答案:

答案 0 :(得分:1)

您应该将editable:true属性用于要包含在“编辑”或“添加”对话框中的列。