summaryrefslogtreecommitdiff
path: root/js/dojo-1.7.2/dojox/data/demos/demo_GoogleSearchStore_Grid.html
blob: 99dacaa84cefca453f3347b368bf04f096116c68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<style type="text/css">
		@import "../../../dojo/resources/dojo.css";
		@import "../../../dijit/themes/tundra/tundra.css";
		@import "../../../dijit/themes/tundra/tundra_rtl.css";
		@import "../../../dijit/tests/css/dijitTests.css";
		@import "../../../dojox/grid/resources/tundraGrid.css";
	</style>

	<title>Google Search Store with Grid</title>

	<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
	<script type="text/javascript">
		dojo.require("dojox.grid.DataGrid");
		dojo.require("dijit.form.TextBox");
		dojo.require("dijit.form.Button");
		dojo.require("dojox.wire.ml.Invocation");
		dojo.require("dojox.wire.ml.Transfer");
		dojo.require("dojox.wire.ml.Action");
		dojo.require("dojox.data.GoogleSearchStore");

		var href = function(value) {
			return "<a href=\"" + value + "\" target=\"_blank\">" + value + "</a>";  
		}
		var layoutResults = [
				[
					{ name: "Title", field: "title", width: 10 },
					{ name: "Summary", field: "content", width: "auto"},
					{ name: "URL", field: "url", width: 20, formatter: href }
				]
		];
		var newQuery = {text: 'dojo ajax' }; 
	</script>
</head>
<body class="tundra" style="margin:20px;">
	<h1>dojox.data.GoogleSearchStore:</h1>
	<i>Displays a list of results from a google query.</i>
	<div dojoType="dojox.data.GoogleSearchStore" jsId="googleStore"></div>
	<br>
	<br>
	<div dojoType="dijit.form.TextBox" id="searchText" value="dojo ajax"></div> 
	<button dojoType="dijit.form.Button" id="searchButton">Search</button>
	<br>
	<br>
	<br>

	<div dojoType="dojox.grid.DataGrid" 
		rowsPerPage="8"
		store="googleStore" 
		structure="layoutResults" 
		query="{ text: 'dojo ajax' }"
		jsId="grid"
		style="width: 800px; height: 500px;"
		>
	</div>
	
	<!-- 
		Link the button to updating the query, then triggering the refresh of the grid. 
		Handy use of dojox.wire!
	-->    
	<div dojoType="dojox.wire.ml.Action"
		trigger="searchButton"
		triggerEvent="onClick">
		<div dojoType="dojox.wire.ml.Transfer" source="searchText.value" target="newQuery.text"></div>
		<div dojoType="dojox.wire.ml.Invocation" object="grid" method="setQuery" parameters="newQuery"></div>
	</div>    
</body>
</html>