2015-06-25 55 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 

希望有所幫助!