javascript - 创建 jqgrid local 时出错

标签 javascript jqgrid

我尝试创建一个 jqgrid 本地:

这是我的代码:

  var mydata=
        [
         {example1:"example1", example2:"2007-10-01",example3:"example "},
        ]
    $("#grid_plan_accion").jqGrid({
        datatype:'local',
        data: mydata,
        colNames:['example1', 'example2',' example3'],
        colModel:[
            { label: 'example1', name: 'example1', width: 20, sorttype:"string", editable:true},
            { label: 'example2', name: 'example2', width: 20, sorttype:"string", editable:true},
            { label: 'example3', name: 'example3', width: 20, sorttype:"string", editable:true},
        ],
        rowNum:10,
        pager: '#pager_plan_accion',
        editurl: 'clientArray',
        width: 150,
        height: 150,
        shrinkToFit: true,

    });

我没有收到错误,只是不显示 jqgrid,我不知道我的错误是什么?请提供任何建议或链接来创建示例,谢谢

最佳答案

        var mydata =
            [
                { example1: "example1", example2: "2007-10-01", example3: "example " },
            ]

        $("#grid_plan_accion").jqGrid({
            datatype: 'json',
            data: mydata,
            colNames: ['example1', 'example2', ' example3'],
            colModel: [
                { label: 'example1', name: 'example1', width: 150, sorttype: "string", editable: true },
                { label: 'example2', name: 'example2', width: 150, sorttype: "string", editable: true },
                { label: 'example3', name: 'example3', width: 150, sorttype: "string", editable: true },
            ],
            rowNum: 10,
            height: 250,
            shrinkToFit: true,

        });
        for (var i = 0; i <= mydata.length; i++)
            jQuery("#grid_plan_accion").jqGrid('addRowData', i + 1, mydata[i]);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/js/jquery.jqGrid.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/css/ui.jqgrid.css" />
<table id="grid_plan_accion"></table>

关于javascript - 创建 jqgrid local 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51064362/

相关文章:

jqgrid - 在列中添加图标而不是文本

javascript - Chrome Extension runtime.sendmessage 等待响应

javascript - Jquery 的函数式 javascript 示例,函数式 js 的大师

javascript - 当我将鼠标悬停在 Button 上以增加其大小时,其下方的元素会向下移动

jquery - 来自 USGS geojson 数据的 jqGrid

jquery - 合并jqgrid中的两个字段

javascript - 如果 JSON 对象位于嵌套数组中,如何使用 Mustache.js?

javascript - 单击时缩放多个 div

javascript - 重新排序列、虚拟滚动、jqgrid 中的 gridResize 不起作用

javascript - 支持 jqGrid 中未知数量的层次结构