Ticket #6021: 6021.patch
| File 6021.patch, 5.3 kB (added by haysmark, 5 months ago) |
|---|
-
form/ComboBox.js
27 27 // Reference to data provider object used by this ComboBox 28 28 store: null, 29 29 30 // fetchProperties: Object 31 // Mixin to the dojo.data store's fetch. 32 // For example, to set the sort order of the ComboBox menu, pass: 33 // {sort:{attribute:"name",descending:true}} 34 fetchProperties:{}, 35 30 36 // query: Object 31 37 // A query that can be passed to 'store' to initially filter the items, 32 38 // before doing further filtering based on `searchAttr` and the key. … … 520 526 // otherwise, if the user types and the last query returns before the timeout, 521 527 // _lastQuery won't be set and their input gets rewritten 522 528 this.searchTimer=setTimeout(dojo.hitch(this, function(query, _this){ 523 var dataObject = this.store.fetch({529 var fetch = { 524 530 queryOptions: { 525 531 ignoreCase: this.ignoreCase, 526 532 deep: true … … 534 540 }, 535 541 start:0, 536 542 count:this.pageSize 537 }); 543 }; 544 dojo.mixin(fetch, _this.fetchProperties); 545 var dataObject = _this.store.fetch(fetch); 538 546 539 547 var nextSearch = function(dataObject, direction){ 540 548 dataObject.start += dataObject.count*direction; … … 587 595 588 596 constructor: function(){ 589 597 this.query={}; 598 this.fetchProperties={}; 590 599 }, 591 600 592 601 postMixInProperties: function(){ … … 1072 1081 items = dojo.query("> option", this.root).filter(function(option){ 1073 1082 return (option.innerText || option.textContent || '').match(matcher); 1074 1083 } ); 1084 if(args.sort){ 1085 items.sort(dojo.data.util.sorter.createSortFunction(args.sort, this)); 1086 } 1075 1087 findCallback(items, args); 1076 1088 }, 1077 1089 -
tests/form/test_ComboBox.html
56 56 query:{type:'country'}, 57 57 searchAttr:"name" 58 58 }, dojo.byId("progCombo2")); 59 60 new dijit.form.ComboBox({ 61 name:"prog3", 62 autoComplete:false, 63 store:store2, 64 query:{type:'country'}, 65 searchAttr:"name", 66 fetchProperties: {sort:[{attribute: 'name', descending: true}]} 67 }, dojo.byId("progCombo3")); 59 68 } 60 69 dojo.addOnLoad(init); 61 70 … … 89 98 onChange="dojo.byId('oc1').value=arguments[0]" 90 99 pageSize="30" 91 100 > 92 <option></option>93 101 <option>Alabama</option> 94 102 <option>Alaska</option> 95 103 <option>American Samoa</option> … … 240 248 <p>A ComboBox with an initial query. (Limits list to items with type = country.)</p> 241 249 <input id="progCombo2"> 242 250 <hr> 251 <p>A ComboBox with an ItemFileReadStore and a descending sort. (Limits list to items with type = country.)</p> 252 <input id="progCombo3"> 253 <hr> 254 <p>A ComboBox with a option tags, autoComplete=true, pageSize=30, and a descending sort.</p> 255 <select 256 name="state6" 257 dojoType="dijit.form.ComboBox" 258 style="width:50%;font-size:200%;font-family:Courier;" 259 name="foo.bar1" 260 autoComplete="true" 261 onChange="dojo.byId('oc1').value=arguments[0]" 262 pageSize="30" 263 fetchProperties="{sort:[{attribute: 'name', descending: true}]}" 264 > 265 <option>Alabama</option> 266 <option>Alaska</option> 267 <option>American Samoa</option> 268 <option>Arizona</option> 269 <option>Arkansas</option> 270 <option>Armed Forces Europe</option> 271 <option>Armed Forces Pacific</option> 272 <option>Armed Forces the Americas</option> 273 <option>California</option> 274 <option>Colorado</option> 275 <option>Connecticut</option> 276 <option>Delaware</option> 277 <option>District of Columbia</option> 278 <option>Federated States of Micronesia</option> 279 <option>Florida</option> 280 <option>Georgia</option> 281 <option>Guam</option> 282 <option>Hawaii</option> 283 <option>Idaho</option> 284 <option>Illinois</option> 285 <option>Indiana</option> 286 <option selected>Iowa</option> 287 <option>Kansas</option> 288 <option>Kentucky</option> 289 <option>Louisiana</option> 290 <option>Maine</option> 291 <option>Marshall Islands</option> 292 <option>Maryland</option> 293 <option>Massachusetts</option> 294 <option>Michigan</option> 295 <option>Minnesota</option> 296 <option>Mississippi</option> 297 <option>Missouri</option> 298 <option>Montana</option> 299 <option>Nebraska</option> 300 <option>Nevada</option> 301 <option>New Hampshire</option> 302 <option>New Jersey</option> 303 <option>New Mexico</option> 304 <option>New York</option> 305 <option>North Carolina</option> 306 <option>North Dakota</option> 307 <option>Northern Mariana Islands</option> 308 <option>Ohio</option> 309 <option>Oklahoma</option> 310 <option>Oregon</option> 311 <option>Pennsylvania</option> 312 <option>Puerto Rico</option> 313 <option>Rhode Island</option> 314 <option>South Carolina</option> 315 <option>South Dakota</option> 316 <option>Tennessee</option> 317 <option>Texas</option> 318 <option>Utah</option> 319 <option>Vermont</option> 320 <option>Virgin Islands, U.S.</option> 321 <option>Virginia</option> 322 <option>Washington</option> 323 <option>West Virginia</option> 324 <option>Wisconsin</option> 325 <option>Wyoming</option> 326 <hr> 243 327 <input type="button" value="Create one in a window" onclick="var win=window.open(window.location);"></input> 244 328 <input type="submit"> 245 329