对话框中的Dojo数据网格会导致加载时出现解析错误

时间:2013-05-07 14:43:46

标签: datagrid dojo dialog

我正在尝试在dojo对话框中使用dojo数据网格,并且在尝试加载页面时出现以下dojo / parse错误。

dojo / parser :: parse()错误(新的TypeError(“d(...)未定义”,“http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojox//grid/DataGrid.js”,16))

如果我注释掉require DataGrid语句,则解析错误就会消失。请注意,我甚至还没有尝试创建数据网格。只是想建立一个简单的骨骼页面。

以下是该页面的代码。

<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Dojo Dialog with DataGrid</title>
        <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" media="screen">
        <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojox/grid/resources/Grid.css" />
        <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojox/grid/resources/claroGrid.css" />
        <!-- load dojo and provide config via data attribute -->
        <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js" data-dojo-config="isDebug: true, async: true, parseOnLoad: true"></script>
        <script>
            require(["dojo/parser", "dijit/Dialog", "dijit/form/Button"]);
            require([
                "dojox/grid/DataGrid",
                "dojox/grid/cells",
                "dojo/store/Memory",
                "dojo/data/ObjectStore",
                "dojo/_base/array",
                "dojo/_base/lang",
                "dojox/grid/_CheckBoxSelector",
                "dojo/domReady!",
            ]);
            //var grid2x;
        </script>
    </head>
    <body class="claro">
    <div data-dojo-type="dijit/Dialog" data-dojo-id="myFormDialog" title="Form Dialog"
    execute="alert('submitted w/args:\n' + dojo.toJson(arguments[0], true));">

        <div class="dijitDialogPaneContentArea">
        </div>

        <div class="dijitDialogPaneActionBar">
            <button data-dojo-type="dijit/form/Button" type="submit" onClick="return myFormDialog.isValid();">
                OK
            </button>
            <button data-dojo-type="dijit/form/Button" type="button" onClick="myFormDialog.hide()">
                Cancel
            </button>
        </div>
    </div>

    <p>When pressing this button the dialog will popup:</p>
    <button id="buttonThree" data-dojo-type="dijit/form/Button" type="button" onClick="myFormDialog.show();">
        Show me!
    </button>

    </body>
</html>

2 个答案:

答案 0 :(得分:0)

即使这篇文章已经过时了,你的问题似乎是"dojo/domReady!,"之后的逗号。上次导入后应该没有逗号。同时加载你想要加载的所有内容,而不是<script> require(["dojo/parser", "dijit/Dialog", "dijit/form/Button"]); require([ "dojox/grid/DataGrid", "dojox/grid/cells", "dojo/store/Memory", "dojo/data/ObjectStore", "dojo/_base/array", "dojo/_base/lang", "dojox/grid/_CheckBoxSelector", "dojo/domReady!", ]); //var grid2x; </script> 只需将所有要求放在一个要求如下: <script> require(["dojo/parser", "dijit/Dialog", "dijit/form/Button", "dojox/grid/DataGrid", "dojox/grid/cells", "dojo/store/Memory", "dojo/data/ObjectStore", "dojo/_base/array", "dojo/_base/lang", "dojox/grid/_CheckBoxSelector", "dojo/domReady!"]);
//var grid2x; </script>

答案 1 :(得分:0)

问题是<html lang="en">。如果lang =&#34; en&#34;,解析器无法解析html组件。删除它或覆盖data-dojo-config="lang='en-us'"