Uploaded image for project: 'Keikai'
  1. Keikai
  2. KEIKAI-622

Frozen top cause missing row and header data when switching sheets

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 5.11.0
    • 5.10.0
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      Run attached sample.

      Load page, open developer tools in browser

      navigate to sheet2

      (if error doesn't happen switch from sheet1 and shee2 a few times)

      (if still doesn't happen, reload page and try again from start)

      Current Result

      zk.wpd:29076 Uncaught TypeError: Cannot read properties of undefined (reading 'i')
          at init.$init (zss.wpd:24557:21)
          at new init (zk.wpd:11127:18)
          at init.initHeaders_ (zss.wpd:27613:13)
          at init.$init (zss.wpd:27185:23)
          at new init (zk.wpd:11127:18)
          at init.afterParentChanged_ (zss.wpd:37670:31)
          at init.appendChild (zk.wpd:23181:13)
          at init.setActiveRange (zss.wpd:13240:20)
          at Function._set2 (zk.wpd:12250:38)
          at setter.func (zk.wpd:22997:18)
      

      Expected Result

      no exception 

      Debug Information

      Caused by both client and server-side interactions
      When loading blocks in a page with frozen top row(s), the spreadsheet _visibleArea at server side top boundary is set to the non-frozen first row.
      (if rows 1 to 4 are frozen, row 5 is the top boundary of the _visibleArea)

      During sheet selection, the data returned for the selected sheet is based on the current _visibleArea:

      Spreadsheet.createActiveRange(SpreadsheetCtrl, SSheet, int, int) line: 2013	
      Spreadsheet.updateSheetAttributes(boolean) line: 1132	
      Spreadsheet.setSelectedSheetDirectly(String, boolean, int, int, int, int, int, int) line: 1069	
      SpreadsheetCtrlImpl.setSelectedSheetDirectly(String, boolean, int, int, int, int, int, int, int, int, int, int, int, int) line: 1198	
      SelectSheetCommand.process(AuRequest) line: 83	
      Spreadsheet.service(AuRequest, boolean) line: 3425	
      

      At this point, the visible area is used to find the top boundary of the data to return to client.

      This cause client to receive data missing the top X rows, where X is the number of frozen rows in the previously selected sheet

      Workaround

      <script><![CDATA[ 
                               
      	function sendPreSelectSyncblock(wgt,frozenOffset,now) {
      		var spcmp = wgt.sp.comp,
      			dp = wgt.dp,
      			brange = wgt.activeBlock.range,
      			cachesheet = wgt._wgt._cacheCtrl.getSelectedSheet();
      		if (!cachesheet) return; //ZSS-1181: sometimes it can be null; see Spreadsheet.java#notifyVisibleRangeChange()
      		var rect = wgt._wgt._cacheCtrl.getSelectedSheet().rect;
      	
      		wgt._wgt.fire('onZSSSyncBlock', {
      			sheetId: wgt.sheetid,
      			dpWidth: -1, //dp.width,
      			dpHeight: -1, //dp.height,
      			viewWidth: -1, //spcmp.clientWidth,
      			viewHeight: -1, //spcmp.clientHeight,
      			blockLeft: brange.left,
      			blockTop: brange.top - frozenOffset,
      			blockRight: brange.right,
      			blockBottom: brange.bottom,
      			fetchLeft: -1,
      			fetchTop: -1,
      			fetchWidth: -1,
      			fetchHeight: -1,
      			rangeLeft: rect.left,
      			rangeTop: rect.top,
      			rangeRight: rect.right,
      			rangeBottom: rect.bottom
      		}, now ? {toServer: true} : null, (now ? 25 : -1));
      	}
                               
      	zk.afterLoad("zss", function () {
      	    var _xSheetSelector = {};
      	    zk.override(zss.SheetSelector.prototype, _xSheetSelector, {
      	        doSelectSheet: function(sheetId, ignoreStatus) {
          			var	wgt = this._wgt,
          				sheet = wgt.sheetCtrl,
          				currSheetId = wgt.getSheetId();
      	        	if(sheet.frozenRow){
      	    		 	wgt._cacheCtrl.releaseCache(wgt.getSheetId());
      		        	sendPreSelectSyncblock(sheet, sheet.frozenRow + 1, false);
      	        	}
      	        	if (sheetId != currSheetId) {
      					var result = _xSheetSelector.doSelectSheet.apply(this, arguments);
      					return result;
      		        }
      	        }
      	     });
      	});
      ]]></script>
      

      Send an syncBlock request to force the server's _visibleArea to include the frozen rows on top of the current sheet if any before the processing the data request for the new page.
       

            gordonhsu gordonhsu
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: