Skip to content

Commit 98c35a6

Browse files
committed
Merge pull request #19 from tms/slickgrid-sorting
Slickgrid sorting
2 parents 5ae02a1 + f920225 commit 98c35a6

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed
830 Bytes
Loading
833 Bytes
Loading

App/StackExchange.DataExplorer/Scripts/query.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,8 @@ DataExplorer.ready(function () {
778778
'name': columns[i].name,
779779
'field': "col" + i,
780780
'type': columns[i].type.toLowerCase(),
781-
'width': Math.min((widths[i] || 50) + 16, maxWidth)
781+
'width': Math.min((widths[i] || 50) + 16, maxWidth),
782+
'sortable': rows.length <= 5000
782783
};
783784

784785
if (name === 'tags' || name === 'tagname') {
@@ -796,6 +797,15 @@ DataExplorer.ready(function () {
796797

797798
grid = new Slick.Grid(target, rows, columns, options);
798799
grid.onColumnsResized.subscribe(resizeResults);
800+
grid.onSort.subscribe(function (e, args) {
801+
var field = args.sortCol.field;
802+
803+
args.grid.getData().sort(function (lhs, rhs) {
804+
return (args.sortAsc ? 1 : -1) * (lhs[field] == rhs[field] ? 0 : lhs[field] < rhs[field] ? -1 : 1);
805+
});
806+
807+
args.grid.invalidate();
808+
});
799809
}
800810

801811
function ColumnFormatter(response) {

App/StackExchange.DataExplorer/StackExchange.DataExplorer.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@
267267
<Content Include="Content\font-awesome\font\fontawesome-webfont.svg" />
268268
<Content Include="Content\images\help-icon.png" />
269269
<Content Include="Content\images\help-sample-graph.png" />
270+
<Content Include="Content\slickgrid\images\sort-asc.gif" />
271+
<Content Include="Content\slickgrid\images\sort-desc.gif" />
270272
<Content Include="Content\Img\openid\openid-logos.png" />
271273
<Content Include="Content\jquery.autocomplete.css" />
272274
<Content Include="Content\qp\images\arithmetic_expression.gif" />

0 commit comments

Comments
 (0)