Ticket #6690: 6690.patch

File 6690.patch, 2.1 kB (added by haysmark, 8 months ago)

Patch to make ComboBox? smarter on how it determines if 'more' should be shown. Fixes #6690.

  • form/ComboBox.js

     
    319319                                // if they are just previewing the options available. 
    320320                                this._autoCompleteText(zerothvalue); 
    321321                        } 
     322                        dataObject._maxOptions = this._maxOptions; 
    322323                        this._popupWidget.createOptions( 
    323324                                results,  
    324325                                dataObject,  
     
    525526                                                deep: true 
    526527                                        }, 
    527528                                        query: query, 
     529                                        onBegin: dojo.hitch(this, "_setMaxOptions"), 
    528530                                        onComplete: dojo.hitch(this, "_openResultList"),  
    529531                                        onError: function(errText){ 
    530532                                                console.error('dijit.form.ComboBox: ' + errText); 
     
    546548                        }, query, this), this.searchDelay); 
    547549                }, 
    548550 
     551                _setMaxOptions: function(size, request){ 
     552                         this._maxOptions = size; 
     553                }, 
     554 
    549555                _getValueField:function(){ 
    550556                        return this.searchAttr; 
    551557                }, 
     
    767773                                this.domNode.insertBefore(menuitem, this.nextButton); 
    768774                        }, this); 
    769775                        // display "Next . . ." button 
    770                         this.nextButton.style.display = (dataObject.count == results.length) ? "" : "none"; 
    771                         dojo.attr(this.nextButton,"id", this.id + "_next") 
     776                        var displayMore = false; 
     777                        //Try to determine if we should show 'more'... 
     778                        if(dataObject._maxOptions && dataObject._maxOptions != -1){ 
     779                                if((dataObject.start + dataObject.count) < dataObject._maxOptions){ 
     780                                        displayMore = true; 
     781                                }else if((dataObject.start + dataObject.length) > (dataObject._maxOptions - 1)){ 
     782                                        //Weird return from a datastore, where a start + count > maxOptions 
     783                                        //implies maxOptions isn't really valid and we have to go into faking it. 
     784                                        //And more or less assume more if count == results.length 
     785                                        if(dataObject.count == results.length){ 
     786                                                displayMore = true; 
     787                                        } 
     788                                } 
     789                        }else if(dataObject.count == results.length){ 
     790                                //Don't know the size, so we do the best we can based off count alone. 
     791                                //So, if we have an exact match to count, assume more. 
     792                                displayMore = true; 
     793                        } 
     794 
     795                        this.nextButton.style.display = displayMore ? "" : "none"; 
     796                        dojo.attr(this.nextButton,"id", this.id + "_next"); 
    772797                }, 
    773798 
    774799                clearResultList: function(){