想写个网格 在下面有两个按钮 分别实现全选 与 全不选的功能
界面如下:
其中关键语句 :<button dojoType="dijit.form.Button" onClick='dijit.byId("grid").rowSelectCell.toggleAllSelection(true)'>全选</button>
<button dojoType="dijit.form.Button" onClick='dijit.byId("grid").rowSelectCell.toggleAllSelection(false)'>删除</button>
似乎根本没有实现 不知道什么原因。。。
完全的代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
</style>
<script type="text/javascript" src="dojo/dojo.js" djConfig="isDebug:true","parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojox.grid.EnhancedGrid");
dojo.require("dojox.grid.enhanced.plugins.DnD");
dojo.require("dojox.grid.enhanced.plugins.Menu");
dojo.require("dojox.grid.enhanced.plugins.NestedSorting");
dojo.require("dojox.grid.enhanced.plugins.IndirectSelection");
dojo.require("dojox.data.CsvStore");
dojo.require('dijit.form.Button');
dojo.require('dojo.parser');
dojo.addOnLoad(function() {
// our test data store for this example:
var store = new dojox.data.CsvStore({
url: 'dojox/grid/compat/tests/support/movies.csv'
});
// set the layout structure:
var layout = [{
field: 'Title',
name: '名字',
width: '200px'
},
{
field: 'Year',
name: '年份',
width: '50px'
},
{
field: 'Producer',
name: '时间',
width: 'auto'
}];
// create a new grid:
var grid = new dojox.grid.EnhancedGrid({
query: {
Title: '*'
},
store: store,
rowSelector: '20px',
structure: layout,
plugins: {
nestedSorting: true,
dnd: true,
indirectSelection: {
name: "Selection",
width: "70px",
styles: "text-align: center;"
}
}
},
document.createElement('div'));
// append the new grid to the div "gridContainer4":
dojo.byId("gridDiv").appendChild(grid.domNode);
// Call startup, in order to render the grid:
grid.startup();
});
</script>
<script type="dojo/method" event="onClick" >
</script>
<link rel="stylesheet" type="text/css" url="dijit/themes/claro/claro.css"
/>
<style type="text/css">
@import "dojo/resources/dojo.css";
@import "dijit/themes/claro/claro.css";
@import "dojox/grid/enhanced/resources/claro/EnhancedGrid.css";
@import "dojox/grid/enhanced/resources/EnhancedGrid_rtl.css";
.dojoxGrid table { margin: 0; } html, body { width: 70%; height: 70%;
margin: 0; }
</style>
</head>
<body class=" claro ">
<div id="gridDiv" style="width: 100%; height: 100%;">
</div>
<!-- NOTE: the following script tag is not intended for usage in real
world!! it is part of the CodeGlass and you should just remove it when
you use the code -->
<script type="text/javascript">
dojo.addOnLoad(function() {
if (document.pub) {
document.pub();
}
});
</script>
<br />
<button dojoType="dijit.form.Button" onClick='dijit.byId("grid").rowSelectCell.toggleAllSelection(true)'>全选</button>
<button dojoType="dijit.form.Button" onClick='dijit.byId("grid").rowSelectCell.toggleAllSelection(false)'>删除</button>
</body>
</html>
希望明白什么地方不对的人能帮我改改。。。