2015-06-25 48 views
1

我在SAPUI5应用程序中使用Handsontable。我无法滚动到Handsontable Grid,其中列标题保持不变。由于这种情况,当用户单击列标题进行排序时,整个列将被选中,滚动将运行到表中的最后一行。尽管在设置中指定排序,排序并不仅限于第二列。Handsontable Column Selection and Sorting问题

以下是我的代码,其后是截图。请帮我解决这个问题。

查看:

<HTML xmlns="sap.ui.core" busy="false" busyIndicatorDelay="1000" visible="true" 
content="&lt;div id='batchesSheet' class='hot handsontable' style='width: 90%; overflow: hidden'&gt;&lt;/div&gt;" 
preferDOM="true" sanitizeContent="false" afterRendering="BatchesHOT"> 
</HTML> 

控制器:

hotBatches = new Handsontable(container, { 
    data: batchesData, 
    rowHeaders: true, 
    columns: [{data: "User", readOnly: true}, {data: "Timestamp", readOnly: true}, {data: "Status", readOnly: true}, { 
     data: "Remarks", 
     readOnly: true 
    }], 
    colHeaders: ["USER", "BATCH SUBMISSION TIME", "STATUS", "REMARKS"], 
    colWidths: [100, 220, 180, 350], 
    columnSorting: { 
     column: 2, 
     sortOrder: true 
    }, 
    sortIndicator: true, 
    contextMenu: true, 
    search: true, 
    outsideClickDeselects: false, 
    cells: function (row, col, prop) { 
     var cellProperties = {}; 

     if (col === 2) { 
     cellProperties.renderer = "statusRenderer"; 
     } 
     else { 
     cellProperties.renderer = "textRenderer"; 
     } 
     return cellProperties; 
    } 
}); 

enter image description here

+0

对不起,这是什么问题?是否希望标题保持冻结?或者当你排序时,你的桌子一直滚动到底部?或两者?第一个问题是你的'overflow:hidden'选项 – ZekeDroid

+0

都是@ZekeDroid。这两个都是问题! –

回答

0

好吧,所以解决这两个问题,你会做到以下几点:

为了使您的头保持冻结,你将以下添加到您的表的初始化:

fixedRowsTop: 0 

要获得滚动更好的工作,加入overflow:auto而不是overflow:hidden就像你拥有了它,现在你的HTML对象。滚动一路底部是我不知道是什么导致它,而是让它滚动到顶部的错误,只是把一个呼叫在您的更新方法结束这就要求

$("#batchesSheet")[0].scrollTop = 0; // sets scroll all the way to the top 

希望有所帮助!