| 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>dojox.grid.Grid - Image Search Test</title> |
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> |
| 7 | <style> |
| 8 | @import "../resources/Grid.css"; |
| 9 | body { |
| 10 | font-size: 0.9em; |
| 11 | font-family: Geneva, Arial, Helvetica, sans-serif; |
| 12 | } |
| 13 | .grid { |
| 14 | height: 30em; |
| 15 | width: 51em; |
| 16 | border: 1px solid silver; |
| 17 | } |
| 18 | #info { width: 700px; } |
| 19 | </style> |
| 20 | <script type="text/javascript" src="../../../dojo/dojo.js" |
| 21 | data-dojo-config="debugAtAllCosts: false, isDebug:false, parseOnLoad: true"> |
| 22 | </script> |
| 23 | <script type="text/javascript"> |
| 24 | dojo.require("dijit.dijit"); |
| 25 | dojo.require("dojox.grid.DataGrid"); |
| 26 | dojo.require("dojo.io.script"); |
| 27 | dojo.require("dojox.rpc.Service"); |
| 28 | dojo.require("dojox.data.ServiceStore"); |
| 29 | dojo.require("dojo.parser"); |
| 30 | </script> |
| 31 | <script type="text/javascript" src="yahooSearch.js"></script> |
| 32 | <script type="text/javascript"> |
| 33 | var service = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc.SMDLibrary", "yahoo.smd")); |
| 34 | var store = new YahooStore({ service: service.imageSearch }); |
| 35 | |
| 36 | // Define grid structure |
| 37 | // remove the height from the header image cell / row cells have a default height so there's less adjustment when thumb comes in. |
| 38 | beforeImageRow = function(inRowIndex, inSubRows){ |
| 39 | inSubRows[0].hidden = (inRowIndex == -1); |
| 40 | } |
| 41 | |
| 42 | var imageLayout = { |
| 43 | onBeforeRow: beforeImageRow, |
| 44 | width: 'auto', |
| 45 | cells: [ |
| 46 | { name: 'Image', cellStyles: "height: 100px;", styles: "text-align: center;", width: 12, get: getImage, formatter: formatImage }, |
| 47 | { name: 'Image', cellStyles: "height: 100px;", styles: "text-align: center;", width: 12, get: getImage, formatter: formatImage }, |
| 48 | { name: 'Image', cellStyles: "height: 100px;", styles: "text-align: center;", width: 12, get: getImage, formatter: formatImage }, |
| 49 | { name: 'Image', cellStyles: "height: 100px;", styles: "text-align: center;", width: 12, get: getImage, formatter: formatImage } |
| 50 | ] |
| 51 | }; |
| 52 | |
| 53 | // execute search |
| 54 | doSearch = function() { |
| 55 | var value = dojo.byId("searchInput").value; |
| 56 | grid.filter({ query: value }, true); |
| 57 | } |
| 58 | |
| 59 | dojo.addOnLoad(function(){ |
| 60 | dojo.query("#searchInput").onkeypress(function(e){ |
| 61 | if(e.keyCode == dojo.keys.ENTER){ doSearch(); } |
| 62 | }); |
| 63 | }); |
| 64 | </script> |
| 65 | </head> |
| 66 | <body> |
| 67 | <h3>dojox.grid.Grid - Image Search Test</h3> |
| 68 | <input id="searchInput" type="text" value="apple"> |
| 69 | <button onclick="doSearch()" style="clear: both;">Search</button> |
| 70 | <div dojoType="dojox.grid.DataGrid" |
| 71 | id="grid" data-dojo-id="grid" class="grid" structure="imageLayout" |
| 72 | store="store" elasticView="1" query="{ query: 'apple' }" |
| 73 | rowSelector="20px"> |
| 74 | </div> |
| 75 | <br> |
| 76 | <div id="info"> |
| 77 | <div id="rowCount" style="float: left"></div> |
| 78 | <div style="float: right"> |
| 79 | <div id="sendInfo" style="text-align: right"></div> |
| 80 | <div id="receiveInfo" style="text-align: right"></div> |
| 81 | </div> |
| 82 | </div> |
| 83 | </body> |
| 84 | </html> |