0

I am following this example.

I am working on a plugin that will keep grouped columns sorted ascending. I am following the test example from the link above. I am getting this error:

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

with this plugin:

    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);
            }
        }
    });

How should I be creating the return for setting the sort properties?

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);
  };
}
rkralston
  • 386
  • 1
  • 5
  • 20
  • Can you give the code at that sortUtils.js:51 and if it's not in that block the setSortProperties method? – spakmad Aug 13 '18 at 17:15
  • That code is part of the Griddle core, that is not my code. – rkralston Aug 13 '18 at 17:29
  • so you want to be able to sort ascending on more than one column? – spakmad Aug 13 '18 at 17:57
  • I want to be able to sort on multiple columns. Sorting two ascending is an easy case to get started with.. It looks like this might not be the right place. The sortProperties handled by setSortProperties are different than the sortProperties passed into the initial Griddle component. – rkralston Aug 13 '18 at 18:04

0 Answers0