question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using external sort is broken in 0.6.1

See original GitHub issue

In 0.6.1, when using external data and sorting capabilities, the sort ascending / descending component never renders as the checks rely on comparing that.state.sortSettings.sortDirection to ‘asc’ or ‘desc’. Problem is, the sortDirection key is internal value, normally set by griddle when NOT using external sorting. There’s no way to set it from the outside, hence sorting component never renders (it thinks there’s no sorting applied at all).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
fechycommented, Aug 4, 2016

+1

I did some digging:

Because of the return in here:

if (this.props.useExternal) {
    this.props.externalChangeSort(column, this.props.externalSortColumn === column ? !this.props.externalSortAscending : true);
    return;
}

This other part is never reached:

var sortDirectionCycle = columnMeta.sortDirectionCycle ? columnMeta.sortDirectionCycle : [null, 'asc', 'desc'];
 var sortDirection = null;
 // Find the current position in the cycle (or -1).
var i = sortDirectionCycle.indexOf(this.state.sortDirection && column === this.state.sortColumn ? this.state.sortDirection : null);

// Proceed to the next position in the cycle (or start at the beginning).
i = (i + 1) % sortDirectionCycle.length;

 if (sortDirectionCycle[i]) {
            sortDirection = sortDirectionCycle[i];
 } else {
            sortDirection = null;
}
 var state = {
            page: 0,
            sortColumn: column,
            sortDirection: sortDirection
};

 this.setState(state);

Therefore, sortDirection is always undefined, so this part in gridTitle.jdx fails:

if (that.props.sortSettings.sortColumn == col && that.props.sortSettings.sortDirection === 'asc') {
      columnSort = that.props.sortSettings.sortAscendingClassName;
      sortComponent = that.props.useGriddleIcons && that.props.sortSettings.sortAscendingComponent;
 } else if (that.props.sortSettings.sortColumn == col && that.props.sortSettings.sortDirection === 'desc') {
      columnSort += that.props.sortSettings.sortDescendingClassName;
      sortComponent = that.props.useGriddleIcons && that.props.sortSettings.sortDescendingComponent;
}

Hope this helps

1reaction
aclowescommented, Sep 23, 2016

I worked around this with a subclass and patch hack. I’m sure there are better ways but might be useful for someone.

import Griddle from 'griddle-react';

export default class Grid extends Griddle {
  oldGetSortObject = this.getSortObject;
  getSortObject = () => {
    const sortObject = this.oldGetSortObject();
    sortObject.sortDirection = sortObject.sortAscending ? 'asc' : 'desc';
    return sortObject;
  };
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sorting indicator is broken 0.6.0 #449 - GriddleGriddle/Griddle
After update from 0.5.1 to 0.6.0 the triangle that indicates the sort direction is broken. Here is the video with some sort of...
Read more >
Memory-adaptive external sorting - SMU InK
One way to deal with memory fluctuations would be for tbc. DBMS to employ virtual memory techniques to page the buffers of an...
Read more >
Expected time of sorting with external sort algorithm
Consider that the external sort it done in two passes. In the first pass, the input file is read in blocks of some...
Read more >
14.6. External Sorting — OpenDSA Data Structures and ...
When a collection of records is too large to fit in main memory, the only practical way to sort it is to read...
Read more >
Bug listing with status RESOLVED with resolution FIXED as at ...
... is not useable with zsh, and may be broken" status:RESOLVED resolution:FIXED ... Bug:980 - "scsh-0.6.1.ebuild places scsh.1 in wrong dir (correction ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found