Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4890

EE ROD on listbox override scrollToIndex

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 9.6.0
    • 9.5.1.3
    • Components
    • Security Level: Jimmy

      Steps to Reproduce

      Run locally (somehow fiddle causes events to cascade and trigger an additional call)

      https://zkfiddle.org/sample/3scu23s/2-listbox-ee-rod-scroll

      Current Result

      Listbox scroll to item 25

      Expected Result

      Listbox scroll to item 500

      Debug Information

      the scrollToIndex invokation is executed during the command processing, before init pads.

      At this stage, the listbox hasn't triggered onRender, and pads are not initialized

      So it scrolls by a ration of the currently rendered item count instead of the actual requested position

      Workaround

      wait for render if render is pending:

      	<script><![CDATA[ 
      	zk.afterLoad("zul.sel", function () {
      	    var _xListbox = {};
      	    zk.override(zul.sel.Listbox.prototype, _xListbox, {
      	        scrollToIndex: function(index, scrollRatio) {
      		    	function scrollLater(self,selfArgs){
      		    		if(self._pendOnRender){
      		    			setTimeout(function(){scrollLater(self, selfArgs)},0);
      		    		}else{
      		    			_xListbox.scrollToIndex.apply(self, selfArgs);
      		    		}
      		    	}
      		    	scrollLater(this, arguments);
      	        }
      	     });
      	});
      ]]></script>
      

            rudyhuang rudyhuang
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day Original Estimate - 1 day
                1d
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 1 hour
                1d 1h