[651] | 1 | <!doctype html> |
---|
| 2 | <html lang="en"> |
---|
| 3 | <head> |
---|
| 4 | <title>ComboBox - Remote Data</title> |
---|
| 5 | <meta charset="utf-8" /> |
---|
| 6 | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> |
---|
| 7 | <meta name="description" content="%description%" /> |
---|
| 8 | <meta name="keywords" content="" /> |
---|
| 9 | <meta name="author" content="ComponentOne" /> |
---|
| 10 | |
---|
| 11 | <link href="../../themes/rocket/jquery-wijmo.css" rel="stylesheet" type="text/css" /> |
---|
| 12 | |
---|
| 13 | <script src="../../external/jquery-1.8.0.min.js" type="text/javascript"></script> |
---|
| 14 | <script src="../../external/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script> |
---|
| 15 | <link href="../../themes/wijmo/jquery.wijmo-open.2.2.2.css" rel="stylesheet" type="text/css" /> |
---|
| 16 | <link href="../../themes/wijmo/jquery.wijmo.wijcombobox.css" rel="stylesheet" type="text/css" /> |
---|
| 17 | <script src="../../external/jquery.mousewheel.min.js" type="text/javascript"></script> |
---|
| 18 | <script src="../../external/jquery.wijmo-open.all.2.2.2.min.js" type="text/javascript"></script> |
---|
| 19 | <script src="../../wijmo/jquery.wijmo.wijdatasource.js" type="text/javascript"></script> |
---|
| 20 | <script src="../../wijmo/jquery.wijmo.wijcombobox.js" type="text/javascript"></script> |
---|
| 21 | <script id="scriptInit" type="text/javascript"> |
---|
| 22 | $(document).ready(function () { |
---|
| 23 | var proxy = new wijhttpproxy({ |
---|
| 24 | url: "http://ws.geonames.org/searchJSON", |
---|
| 25 | dataType: "jsonp", |
---|
| 26 | data: { |
---|
| 27 | featureClass: "P", |
---|
| 28 | style: "full", |
---|
| 29 | maxRows: 12 |
---|
| 30 | }, |
---|
| 31 | key: 'geonames' |
---|
| 32 | }); |
---|
| 33 | |
---|
| 34 | var myReader = new wijarrayreader([{ |
---|
| 35 | name: 'label', |
---|
| 36 | mapping: function (item) { |
---|
| 37 | return item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName |
---|
| 38 | } |
---|
| 39 | }, { |
---|
| 40 | name: 'value', |
---|
| 41 | mapping: 'name' |
---|
| 42 | }, { |
---|
| 43 | name: 'selected', |
---|
| 44 | defaultValue: false |
---|
| 45 | }]); |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | var datasource = new wijdatasource({ |
---|
| 49 | reader: myReader, |
---|
| 50 | proxy: proxy |
---|
| 51 | }); |
---|
| 52 | $("#tags").wijcombobox({ |
---|
| 53 | data: datasource, |
---|
| 54 | showTrigger: false, |
---|
| 55 | search: function (e, obj) { |
---|
| 56 | obj.datasrc.proxy.options.data.name_startsWith = obj.term.value; |
---|
| 57 | }, |
---|
| 58 | select: function (e, item) { |
---|
| 59 | $('#output').html('I come from ' + item.label + '!'); |
---|
| 60 | } |
---|
| 61 | }); |
---|
| 62 | }); |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | </script> |
---|
| 66 | </head> |
---|
| 67 | <body class="demo-single"> |
---|
| 68 | <div class="container"> |
---|
| 69 | <div class="header"> |
---|
| 70 | <h2> |
---|
| 71 | Remote Data</h2> |
---|
| 72 | </div> |
---|
| 73 | <div class="main demo"> |
---|
| 74 | <!-- Begin demo markup --> |
---|
| 75 | <label for="tags"> |
---|
| 76 | Type 4 chars to lookup a city</label> |
---|
| 77 | <input id="tags" style="width: 300px" /> |
---|
| 78 | <p> |
---|
| 79 | <label id="output"> |
---|
| 80 | </label> |
---|
| 81 | </p> |
---|
| 82 | <!-- End demo markup --> |
---|
| 83 | <div class="demo-options"> |
---|
| 84 | <!-- Begin options markup --> |
---|
| 85 | <!-- End options markup --> |
---|
| 86 | </div> |
---|
| 87 | </div> |
---|
| 88 | <div class="footer demo-description"> |
---|
| 89 | <p> |
---|
| 90 | This sample demonstrates how the <b>search</b> method and event can be used to locate a city name using four values entered in the textbox of wijcombobox. |
---|
| 91 | </p> |
---|
| 92 | </div> |
---|
| 93 | </div> |
---|
| 94 | </body> |
---|
| 95 | </html> |
---|