动态列选择和排序问题

时间:2015-06-25 13:13:30

标签: jquery css html5 sapui5 handsontable

我在SAPUI5应用程序中使用Handsontable。我无法滚动到Handsontable Grid,其中列标题保持固定。由于当用户单击用于对列进行排序的列标题时,将选择整个列,并且滚动将运行到表中的最后一行。此外,尽管在设置中指定了排序,但排序并不仅限于第二列。

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

查看:

<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

1 个答案:

答案 0 :(得分:0)

好的,为了解决这两个问题,你会做以下事情:

要使标题保持冻结状态,请将以下内容添加到表的初始化中:

fixedRowsTop: 0

要让滚动效果更好,请在HTML对象上添加overflow:auto而不是overflow:hidden。滚动到底部是一个错误,我不确定导致它的原因,但要使其滚动到顶部,只需在更新方法结束时调用< / p>

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

希望有所帮助!