1 | dojo.declare("YahooStore", dojox.data.ServiceStore, { |
---|
2 | _processResults: function(results, def){ |
---|
3 | var totalCount = 0; |
---|
4 | if(results.ResultSet){ |
---|
5 | totalCount = results.ResultSet.totalResultsAvailable; |
---|
6 | results = results.ResultSet.Result; |
---|
7 | } |
---|
8 | var resultSet = this.inherited(arguments); |
---|
9 | resultSet.totalCount = totalCount > 1000 ? 1000 : totalCount; |
---|
10 | return resultSet; |
---|
11 | }, |
---|
12 | fetch: function(request){ |
---|
13 | if(request.query){ |
---|
14 | if(request.count){ |
---|
15 | request.query['results'] = request.count; |
---|
16 | } |
---|
17 | if(typeof request.start != "undefined"){ |
---|
18 | request.query['start'] = request.start + 1; |
---|
19 | } |
---|
20 | } |
---|
21 | |
---|
22 | return this.inherited(arguments); |
---|
23 | } |
---|
24 | }); |
---|
25 | |
---|
26 | var getCellData = function(item, field){ |
---|
27 | return grid.store.getValue(item, field); |
---|
28 | }; |
---|
29 | |
---|
30 | var getLink = function(inRowIndex, inItem){ |
---|
31 | if(!inItem){ return ' '; } |
---|
32 | return { |
---|
33 | text: getCellData(inItem, 'Title'), |
---|
34 | href: getCellData(inItem, 'ClickUrl') |
---|
35 | }; |
---|
36 | }; |
---|
37 | |
---|
38 | var formatLink = function(result){ |
---|
39 | return typeof result == 'object' ? dojo.string.substitute( |
---|
40 | '<a target="_blank" href="${href}">${text}</a>', |
---|
41 | result |
---|
42 | ) : result; |
---|
43 | } |
---|
44 | |
---|
45 | var formatDate = function(inDatum, inRowIndex){ |
---|
46 | if(!inDatum){ return ' '; } |
---|
47 | var d = new Date(inDatum * 1000); |
---|
48 | return dojo.string.substitute( |
---|
49 | "${0}/${1}/${2}", |
---|
50 | [ d.getMonth()+1, d.getDate(), d.getFullYear() ] |
---|
51 | ); |
---|
52 | }; |
---|
53 | |
---|
54 | var getImage = function(inRowIndex, inItem){ |
---|
55 | if(!inItem){ return ' '; } |
---|
56 | var thumb = getCellData(inItem, "Thumbnail"); |
---|
57 | return { |
---|
58 | href: getCellData(inItem, "ClickUrl"), |
---|
59 | src: thumb.Url, |
---|
60 | width: thumb.Width, |
---|
61 | height: thumb.Height |
---|
62 | }; |
---|
63 | }; |
---|
64 | |
---|
65 | var formatImage = function(result){ |
---|
66 | return typeof result == "object" ? dojo.string.substitute( |
---|
67 | '<a href="${href}" target="_blank"><img border=0 src="${src}" width="${width}" height="${height}"></a>', result) : |
---|
68 | result; |
---|
69 | } |
---|
70 | |
---|
71 | var getDimensions = function(inRowIndex, inItem){ |
---|
72 | if(!inItem){ return ' '; } |
---|
73 | var w = getCellData(inItem, "Width"); |
---|
74 | var h = getCellData(inItem, "Height"); |
---|
75 | return w + ' x ' + h; |
---|
76 | }; |
---|