javascript - Dojo增强网格可编辑问题

标签 javascript dojox.grid dojo

我在使我的 dojo EnhancedGrid 可编辑时遇到问题。 目前,我可以双击网格单元格,并且可以更改值,但是当我再次按 Enter 或尝试离开单元格(即将新值保存到网格中)时,我收到“ItemFileWriteStore 中断言失败”我的 Firebug 中出现错误。

下面是我的源代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
    <style type="text/css">
        body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
    </style>
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css" />
    <style type="text/css">
        @import "http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/Grid.css";
        @import "http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/claroGrid.css";
        .dojoxGrid table { margin: 0; }
    </style>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" djConfig="parseOnLoad: true">
    </script>

    <script type="text/javascript">
        dojo.require("dojox.grid.EnhancedGrid");
        dojo.require("dojo.data.ItemFileWriteStore");
        dojo.require("dojox.grid.cells._base");

        dojo.addOnLoad(function() {

            var layoutabc = 
            [[
                {
                    field: "title",
                    name: "TitleofMovie",
                    width: "300px",
                    editable: true
                },
                {
                    field: "year",
                    name: "Year",
                    width: "200px",
                    editable: true
                },
                {
                    field: "producer",
                    name: "Producer",
                    width: "auto",
                    editable: true,
                    type: dojox.grid.cells.Cell
                }
            ]];


            var mystore = new dojo.data.ItemFileWriteStore({
                url: "movies.json"
            });

            // create a new grid:
            var grid = new dojox.grid.EnhancedGrid(
                {
                    query: {},
                    store: mystore,
                    structure: layoutabc
                },
                document.createElement("div")
            );
            dojo.byId("gridDiv").appendChild(grid.domNode);

            grid.startup();
        });
    </script>
</head>

<body class="claro">
    <div id="gridDiv" style="width: 800px; height: 400px;">
    </div>
</body>

这是我的 movie.json 的内容(我知道数据的内容很奇怪):

{
    items: 
    [
        {
            title: "Africa",
            year: "continent",
            producer: "Katia Lund"
        },
        {
            title: "Kenya",
            year: "country",
            producer: "Christine Jeffs"
        },
        {
            title: "Mombasa",
            year: "city",
            producer: "Ridley Scott"
        }
    ]
}

最佳答案

问题已解决。结果我需要为EnhancedGrid对象定义“plugins”属性,即使它只是一个空对象。一旦定义它就可以正常工作。

关于javascript - Dojo增强网格可编辑问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4435578/

相关文章:

javascript - Canvas 中的 Particle.js 错误高度

DataGrid 的 Dojo 滚动问题

dojox.grid - 如何聚焦在 dojox.grid.DataGrid 中新添加行的第一个单元格

dojo - 带有单选按钮的 Dijit.tree 扩展提交了错误的值

javascript - 使用 node-inspector 和 forever.js 调试 node.js

javascript - 非 https 上的地理定位仍然可以在 Ionic 应用程序上使用吗?

javascript - 道场网格: accessing another attribute from a formatter

dojo - Dojo 的 TimeTextBox 中的范围

dojo - 应用拖放属性后,文本框变得不可编辑(dojo/dnd/Source)

instagram 嵌入加载后的 Javascript 回调?