0

我正在使用 angular-slickgrid:“^2.17.11”。我对它很陌生。这是我配置网格选项以显示分页和每页项目的方式。在配置中,我将页面大小指定为 [5, 10, 15, 20, 25, 50, 75] 但在 UI 中它是 [5, 10, 15, 20, 25, 50, 75, 75, 100]。不知道它是如何发生的。我错过了什么吗?

{
      enableSorting: true,
      enableFiltering: true,
      enablePagination: true,
      pagination: {
        pageSizes: [5, 10, 15, 20, 25, 50, 75],
        pageSize: 5
      },
      autoResize: {
        containerId: 'tableSection_details',
        sidePadding: 5
      },
      alwaysShowVerticalScroll: false,
      excelExportOptions: {
        filename: "DoC",
        sheetName: this._exportSheetName
      },
      enableExcelExport: true,
      gridMenu: {
        onCommand: (e, args) => {
          if (args.command === 'toggle-preheader') {
            // in addition to the grid menu pre-header toggling (internally), we will also clear grouping
            this.clearGrouping();
          }
        },
      },
      enableDraggableGrouping: true,
      createPreHeaderPanel: true,
      showPreHeaderPanel: true,
      preHeaderPanelHeight: 40,
      draggableGrouping: {
        dropPlaceHolderText: 'Drop column header here to group by the column',
        deleteIconCssClass: 'fa fa-times',
        onGroupChanged: (e, args) => this.onGroupChanged(args),
        onExtensionRegistered: (extension) => this.draggableGroupingPlugin = extension,
      }
    }
4

1 回答 1

1

请注意,我是 Angular-Slickgrid 的作者。

这是 Angular-Slickgrid 库中的一个错误,并在此PR中得到了修复。然而,一个新版本还要等一周左右。(现已修复并发布,请参阅版本

代码现在将在内部检查用户是否提供了自定义页面大小,如果是,将使用它们,否则它将使用在全局网格选项中定义的那些(默认为[5, 10, 15, 20, 25, 50, 75, 100])。

代码修复

// using jQuery extend to do a deep clone has an unwanted side on objects and pageSizes but ES6 spread has other worst side effects
// so we will just overwrite the pageSizes when needed, this is the only one causing issues so far.
// jQuery wrote this on their docs:: On a deep extend, Object and Array are extended, but object wrappers on primitive types such as String, Boolean, and Number are not.
if (gridOptions.enablePagination && gridOptions.pagination && Array.isArray(gridOptions.pagination.pageSizes)) {
    options.pagination.pageSizes = gridOptions.pagination.pageSizes;
}

编辑

这已在新的 Angular-Slickgrid 新版本下得到修复并可用

于 2020-05-15T02:21:33.797 回答