I'm working in Xpages and attempting to create my first dojo data grid. I have a grid of data. However, I think I'm missing a css class somewhere because the column sort options don't look correct and the filter prompt window is way too small, resulting in everything being bunched up and unreadable / unusable. What am I missing?
Here is the source:
<?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="dojo.data.ItemFileWriteStore"></xp:dojoModule>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dijit/themes/tundra/tundra.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': '40px'},
{'field': "cusno", 'name': "Cust #", 'width': '60px'},
{'field': "cusnm", 'name': "Customer", 'width': '150px'},
{'field': "qtamt", 'name': "Quote Amt", 'width': '40px', 'datatype':'number'},
]
}]
//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 = data_list.length;
//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 dojo.data.ItemFileWriteStore({data: data});
//define the grid
var grid = new dojox.grid.EnhancedGrid({
id: 'grid',
query: {},
store: store,
structure: layout,
rowSelector: '20px',
autoHeight: 125,
plugins:{nestedSorting:true, dnd:true, filter:true}
}, '#{id:gridDiv}');
//create it
grid.startup();
})
]]></xp:this.script>
</xp:executeClientScript>
</xp:this.script></xp:eventHandler></xp:view>
You have a bug in your own code :-) Change your reference to the EnhancedGrid CSS files from /esources to /resources.
<xp:styleSheet>
href="/.ibmxspres/dojoroot/dojox/grid/enhanced/resources/EnhancedGrid.css">
</xp:styleSheet>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/enhanced/resources/tundraEnhancedGrid.css">
</xp:styleSheet>