| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 | "http://www.w3.org/TR/html4/loose.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <title>Test IndirectSelection plugin of dojox.grid.EnhancedGrid</title> |
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> |
| 7 | <link rel=stylesheet href="support/common.css"/> |
| 8 | <style type="text/css"> |
| 9 | body { |
| 10 | font-size: 0.9em; |
| 11 | font-family: Geneva, Arial, Helvetica, sans-serif; |
| 12 | padding: 0.5em; |
| 13 | } |
| 14 | .title { |
| 15 | text-align:center; |
| 16 | } |
| 17 | #grid1, #grid2 { |
| 18 | width: 85.2em; |
| 19 | height: 50em; |
| 20 | } |
| 21 | </style> |
| 22 | <script type="text/javascript" src="../../../../dojo/dojo.js" |
| 23 | data-dojo-config="isDebug:true, parseOnLoad: true"></script> |
| 24 | <script type="text/javascript" src="../../../../dijit/tests/_testCommon.js"></script> |
| 25 | <script type="text/javascript"> |
| 26 | dojo.require("dojox.grid.EnhancedGrid"); |
| 27 | dojo.require("dojox.grid.enhanced.plugins.IndirectSelection"); |
| 28 | dojo.require("dojo.data.ItemFileWriteStore"); |
| 29 | dojo.require("dojo.parser"); |
| 30 | </script> |
| 31 | <script type="text/javascript"> |
| 32 | var data = { |
| 33 | identifier: 'id', |
| 34 | label: 'id', |
| 35 | items: [] |
| 36 | }; |
| 37 | var data_list = [ |
| 38 | { col1: "normal", col2: false, col3: "new", col4: 'But are not followed by two hexadecimal', col5: 29.91, col6: 10, col7: false }, |
| 39 | { col1: "important", col2: false, col3: "new", col4: 'Because a % sign always indicates', col5: 9.33, col6: -5, col7: false }, |
| 40 | { col1: "important", col2: false, col3: "read", col4: 'Signs can be selectively', col5: 19.34, col6: 0, col7: true }, |
| 41 | { col1: "note", col2: false, col3: "read", col4: 'However the reserved characters', col5: 15.63, col6: 0, col7: true }, |
| 42 | { col1: "normal", col2: false, col3: "replied", col4: 'It is therefore necessary', col5: 24.22, col6: 5.50, col7: true }, |
| 43 | { col1: "important", col2: false, col3: "replied", col4: 'To problems of corruption by', col5: 9.12, col6: -3, col7: true }, |
| 44 | { col1: "note", col2: false, col3: "replied", col4: 'Which would simply be awkward in', col5: 12.15, col6: -4, col7: false } |
| 45 | ]; |
| 46 | var rows = 300; |
| 47 | for(var i=0, l=data_list.length; i<rows; i++){ |
| 48 | data.items.push(dojo.mixin({ id: i }, data_list[i%l])); |
| 49 | } |
| 50 | |
| 51 | // global var "test_store" |
| 52 | test_store = new dojo.data.ItemFileWriteStore({data: data}); |
| 53 | |
| 54 | var layout = [[ |
| 55 | {name: 'Column 1', field: 'id'}, |
| 56 | {name: 'Column 2', field: 'col2'}, |
| 57 | {name: 'Column 3', field: 'col3'}, |
| 58 | {name: 'Column 4', field: 'col4', width: "150px"}, |
| 59 | {name: 'Column 5', field: 'col5'}, |
| 60 | {name: 'Column 6', field: 'col6'}, |
| 61 | {name: 'Column 7', field: 'col7'}, |
| 62 | {name: 'Column 8', field: 'col5'} |
| 63 | ]]; |
| 64 | |
| 65 | dojo.addOnLoad(function(){ |
| 66 | grid = new dojox.grid.EnhancedGrid({ |
| 67 | id: "grid1", |
| 68 | store: test_store, |
| 69 | structure: layout, |
| 70 | rowSelector: "20px", |
| 71 | summary: "A customized grid summary", |
| 72 | plugins: {indirectSelection: {headerSelector:true, name: "Selection", width: "60px", styles: "text-align: center;"}} |
| 73 | }); |
| 74 | |
| 75 | dojo.byId("gridDiv").appendChild(grid.domNode); |
| 76 | grid.startup(); |
| 77 | }); |
| 78 | |
| 79 | var disabled = false; |
| 80 | function toggleDisabled(id){ |
| 81 | disabled = !disabled; |
| 82 | for(var i = 0; i < rows; i++){ |
| 83 | dijit.byId(id).rowSelectCell.setDisabled(i, disabled); |
| 84 | } |
| 85 | } |
| 86 | </script> |
| 87 | </head> |
| 88 | <body class="claro"> |
| 89 | <h1 class="title">dojox.grid.EnhancedGrid - IndirectSelection</h1> |
| 90 | <p> |
| 91 | <b>Multiple selection mode:</b> |
| 92 | <div id="gridDiv"></div><br/> |
| 93 | <input type='button' value='Select All' onclick='dijit.byId("grid1").rowSelectCell.toggleAllSelection(true)'/> |
| 94 | <input type='button' value='Deselect All' onclick='dijit.byId("grid1").rowSelectCell.toggleAllSelection(false)'/> |
| 95 | <input type='button' value='Toggle Disabled All' onclick='toggleDisabled("grid1")'/><br/><br/> </p> |
| 96 | <p> |
| 97 | <b> |
| 98 | Single selection mode: |
| 99 | </b> |
| 100 | <div id="grid2" dojoType="dojox.grid.EnhancedGrid" rowsPerPage="30" selectionMode="single" |
| 101 | plugins='{indirectSelection: {name: "Selection", width:"60px", styles:"text-align: left;"}}' |
| 102 | store="test_store" structure="layout" rowSelector="20px"> |
| 103 | </div> |
| 104 | </p> |
| 105 | </body> |
| 106 | </html> |