0

我正在关注这个例子

我正在开发一个插件,该插件将使分组列按升序排序。我正在关注上面链接中的测试示例。我收到此错误:

Uncaught TypeError: Cannot read property 'sortAscending' of undefined at sortUtils.js:51

使用这个插件:

    const setGroupSortPlugin = (groups) => ({
        events: {
            setSortProperties : (sortProperties) => {
                let newSortProperties = [];
                groups.map(group => {
                    newSortProperties.push(
                        {id: group.id, sortAscending: true}
                    )
                })
                newSortProperties.push(
                    { id: sortProperties.columnId, sortAscending: true }
                );
                return setSortProperties(newSortProperties);
            }
        }
    });

我应该如何创建设置排序属性的回报?

function setSortProperties(_ref) {
  var setSortColumn = _ref.setSortColumn,
      sortProperty = _ref.sortProperty,
      columnId = _ref.columnId;

  return function () {
    if (sortProperty === null) {
      setSortColumn({ id: columnId, sortAscending: true });
      return;
    }

    var newSortProperty = _extends({}, sortProperty, {
      sortAscending: !sortProperty.sortAscending
    });

    setSortColumn(newSortProperty);
  };
}
4

0 回答 0