Skip to content

Commit

Permalink
Add simple sorting for tables with <= 5000 results
Browse files Browse the repository at this point in the history
  • Loading branch information
tms committed Dec 24, 2013
1 parent 85082f4 commit d99b211
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion App/StackExchange.DataExplorer/Scripts/query.js
Expand Up @@ -880,7 +880,8 @@ DataExplorer.ready(function () {
'name': columns[i].name,
'field': "col" + i,
'type': columns[i].type.toLowerCase(),
'width': Math.min((widths[i] || 50) + 16, maxWidth)
'width': Math.min((widths[i] || 50) + 16, maxWidth),
'sortable': rows.length <= 50000
};

if (name === 'tags' || name === 'tagname') {
Expand All @@ -898,6 +899,15 @@ DataExplorer.ready(function () {

grid = new Slick.Grid(target, rows, columns, options);
grid.onColumnsResized.subscribe(resizeResults);
grid.onSort.subscribe(function (e, args) {
var field = args.sortCol.field;

args.grid.getData().sort(function (lhs, rhs) {
return (args.sortAsc ? 1 : -1) * (lhs[field] == rhs[field] ? 0 : lhs[field] < rhs[field] ? -1 : 1);
});

args.grid.invalidate();
});
}

function ColumnFormatter(response) {
Expand Down
Expand Up @@ -267,6 +267,8 @@
<Content Include="Content\font-awesome\font\fontawesome-webfont.svg" />
<Content Include="Content\images\help-icon.png" />
<Content Include="Content\images\help-sample-graph.png" />
<Content Include="Content\slickgrid\images\sort-asc.gif" />
<Content Include="Content\slickgrid\images\sort-desc.gif" />
<Content Include="Content\Img\openid\openid-logos.png" />
<Content Include="Content\jquery.autocomplete.css" />
<Content Include="Content\qp\images\arithmetic_expression.gif" />
Expand Down

0 comments on commit d99b211

Please sign in to comment.