我正在使用XPages并尝试首次创建dojo增强型数据网格。我正在按照我在网上找到的例子,但我收到错误:“dojox.data未定义”。我几乎没有发现任何关于这个错误的信息,所以显然它对其他人来说一定是简单的。我有点迷失在这里,有人能指出我正确的方向来解决这个问题吗?
我的目标是从ERP系统查询数据,然后将其显示在网格中。但是,我需要首先使用硬编码数据。
这是我的xpage源:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" dojoParseOnLoad="true"
dojoTheme="true">
<xp:this.resources>
<xp:dojoModule name="dojox.grid.EnhancedGrid"></xp:dojoModule>
<xp:dojoModule name="dojox.grid.enhanced.plugins.DnD"></xp:dojoModule>
<xp:dojoModule
name="dojox.grid.enhanced.plugins.NestedSorting">
</xp:dojoModule>
<xp:dojoModule
name="dojox.grid.enhanced.plugins.IndirectSelection">
</xp:dojoModule>
<xp:dojoModule name="dojox.grid.enhanced.plugins.Filter"></xp:dojoModule>
<xp:dojoModule name="dojox.data.ItemFileWriteStore"></xp:dojoModule>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dijit/themes/dijit.css">
</xp:styleSheet>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/resources/Grid.css">
</xp:styleSheet>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/resources/tundraGrid.css">
</xp:styleSheet>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/enhanced/esources/EnhancedGrid.css">
</xp:styleSheet>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/enhanced/esources/tundraEnhancedGrid.css">
</xp:styleSheet>
</xp:this.resources>
<xp:br></xp:br>
<xp:div id="gridDiv"></xp:div>
<xp:eventHandler event="onClientLoad" submit="false">
<xp:this.script>
<xp:executeClientScript>
<xp:this.script><![CDATA[dojo.addOnLoad(function(){
//setup the grid layout, format = {'name': 'columntitle', 'field': 'fieldname'}
var layout = [{
defaultCell: {editable: false, type: dojox.grid.cells._Widget},
rows:[
{'field': "qtno", 'name': "Quote No.", 'width': '20px'},
{'field': "cusno", 'name': "Cust #", 'width': '20px'},
{'field': "cusnm", 'name': "Customer", 'width': '30px'},
{'field': "qtamt", 'name': "Quote Amt", 'width': '20px'},
]
}]
//setup data store
var data = {
identifier: 'id',
items: []
};
//setup data array of strings, format = {fieldname: "strvalue", fieldname: numvalue}
var data_list = [
{ qtno: "Q01234", cusno: "4419", cusnm: "ABC Corporation", qtamt: 29.91},
{ qtno: "Q42198", cusno: "3308", cusnm: "Acme Company", qtamt: 9.33},
{ qtno: "Q11095", cusno: "7041", cusnm: "XYZ Industries", qtamt: 19.34}
];
//default the rows
var rows = 100;
//populate the store with the data array of strings
for(var i=0, l=data_list.length; i<rows; i++){
data.items.push(dojo.mixin({ id: i+1 }, data_list[i%l]));
}
var store = new dojox.data.ItemFileWriteStore({data: data});
//define the grid
var grid = new dojox.grid.EnhancedGrid({
id: 'grid',
query: {},
store: store,
structure: layout,
rowSelector: '20px',
autoHeight: 25
}, '#{id:gridDiv}');
//create it
grid.startup();
})
]]></xp:this.script>
</xp:executeClientScript>
</xp:this.script></xp:eventHandler></xp:view>
,这是错误:
TypeError: dojox.data is undefined
Stack trace:
view__id1__id3_clientSide_onClientLoad/<@http://domsvr3.mphassoc.com/dev/MiscDev.nsf/DataGrid.xsp:87:9
答案 0 :(得分:0)
dojox.data资源应该是dojo.data。
答案 1 :(得分:0)
使用dojo.data
因为它不再是实验性Dojo包dojox的一部分。