我遇到了使我的dojo增強網格可編輯的問題。 目前,我可以雙擊網格單元格,我可以更改值,但是當我再次按下Enter或嘗試離開單元格(即將新值保存到網格)時,我收到了「ItemFileWriteStore中的斷言失敗「我的螢火蟲錯誤。Dojo增強網格可編輯問題
下面是我的源代碼:
<!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>
這是我movies.json的內容(數據的內容很奇怪,我知道):
{
items:
[
{
title: "Africa",
year: "continent",
producer: "Katia Lund"
},
{
title: "Kenya",
year: "country",
producer: "Christine Jeffs"
},
{
title: "Mombasa",
year: "city",
producer: "Ridley Scott"
}
]
}
附加信息:如果我更改爲使用DataGrid而不是EnhancedGrid,那麼整個事情就會起作用... – Hery 2010-12-14 06:25:51
您是如何解決的? 我有插件設置在「{nestedSorting:true}」,並添加在我的代碼(在添加按鈕)這部分變量gPlugins =「{nestedSorting:true}」; grid.plugins = gPlugins;但沒有什麼變化;當我刷新表格時不要添加該行。 – 2011-10-26 14:26:44
@francesco:我將'plugins'屬性傳遞給了EnhancedGrid本身的構造函數。雖然我懷疑它會有所作爲,但你應該嘗試一下。如果它不能解決你的問題,你應該問一個新的問題,因爲這個問題被問及了一段時間,現在使用的dojo版本可能會有所不同。 – Hery 2011-10-27 02:34:25