| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <style type="text/css"> |
| 6 | @import "../../../dojo/resources/dojo.css"; |
| 7 | @import "../../../dijit/themes/tundra/tundra.css"; |
| 8 | @import "../../../dijit/themes/tundra/tundra_rtl.css"; |
| 9 | @import "../../../dijit/tests/css/dijitTests.css"; |
| 10 | @import "../../../dojox/grid/resources/tundraGrid.css"; |
| 11 | </style> |
| 12 | |
| 13 | <title>Google Search Store with Grid</title> |
| 14 | |
| 15 | <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script> |
| 16 | <script type="text/javascript" src="../../../dijit/dijit.js"></script> |
| 17 | <script type="text/javascript" src="../GoogleSearchStore.js"></script> |
| 18 | <script type="text/javascript"> |
| 19 | dojo.require("dojox.grid.DataGrid"); |
| 20 | dojo.require("dijit.form.TextBox"); |
| 21 | dojo.require("dijit.form.Button"); |
| 22 | dojo.require("dojox.wire.ml.Invocation"); |
| 23 | dojo.require("dojox.wire.ml.Transfer"); |
| 24 | dojo.require("dojox.wire.ml.Action"); |
| 25 | dojo.require("dojox.data.GoogleSearchStore"); |
| 26 | |
| 27 | var ImageSearch; |
| 28 | |
| 29 | dojo.ready(function(){ |
| 30 | ImageSearch = { layout:[], store:{}, grid:{}, } |
| 31 | |
| 32 | ImageSearch.format = function(value, row) { |
| 33 | return "<img src=\"" + value + "\" alt=\"" + ImageSearch.grid.getItem(row).title + "\" style=\"height:80px; width:auto; margin:auto;\">"; |
| 34 | } |
| 35 | |
| 36 | ImageSearch.layout = [ |
| 37 | [ |
| 38 | { name: "Title", field: "title", width: 20 }, |
| 39 | { name: "Summary", field: "content", width: 20 }, |
| 40 | { name: "URL", field: "url", width: "auto", formatter: ImageSearch.format } |
| 41 | ] |
| 42 | ]; |
| 43 | |
| 44 | ImageSearch.store = new dojox.data.GoogleImageSearchStore(); |
| 45 | |
| 46 | ImageSearch.grid = new dojox.grid.DataGrid({ |
| 47 | store: ImageSearch.store, |
| 48 | structure: ImageSearch.layout, |
| 49 | query: { text: 'cat' }, |
| 50 | style: "width: 720px; height: 500px;", |
| 51 | rowsPerPage: 20, |
| 52 | escapeHTMLInData: false |
| 53 | }, "googleGrid"); |
| 54 | |
| 55 | ImageSearch.grid.startup(); |
| 56 | |
| 57 | }); |
| 58 | |
| 59 | var newQuery = {text: 'cat' }; |
| 60 | </script> |
| 61 | </head> |
| 62 | <body class="tundra" style="margin:20px;"> |
| 63 | <h1>dojox.data.GoogleImageSearchStore:</h1> |
| 64 | <i>Displays a list of results from a google image search.</i><br> |
| 65 | <div dojoType="dijit.form.TextBox" id="searchText" value="cat"></div> |
| 66 | <button dojoType="dijit.form.Button" id="searchButton">Search</button> |
| 67 | <br> |
| 68 | <br> |
| 69 | <div id="googleGrid"></div> |
| 70 | <div dojoType="dojox.wire.ml.Action" trigger="searchButton" triggerEvent="onClick"> |
| 71 | <div dojoType="dojox.wire.ml.Transfer" source="searchText.value" target="newQuery.text"></div> |
| 72 | <div dojoType="dojox.wire.ml.Invocation" object="ImageSearch.grid" method="setQuery" parameters="newQuery"></div> |
| 73 | </div> |
| 74 | </body> |
| 75 | </html> |