我正在关注此MDN。
我正在开发一个插件,它将使分组的列保持升序排列。我正在从上面的链接跟踪测试示例。我收到此错误:
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);
};
}