-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #88
- Loading branch information
Showing
3 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Bootstrap Sortable Tables</title> | ||
</head> | ||
<body> | ||
<table class="table table-striped table-bordered sortable"> | ||
<thead> | ||
<tr> | ||
<th data-defaultsort="asc">head1</th> | ||
<th id="outerh2">head2</th> | ||
<th>head3</th> | ||
<th>head4</th> | ||
</tr> | ||
</thead> | ||
<tbody id="outer"> | ||
<tr> | ||
<td>2</td> | ||
<td>hi</td> | ||
<td>2015/04/08</td> | ||
<td>5.234</td> | ||
</tr> | ||
<tr> | ||
<td>5</td> | ||
<td>yeah</td> | ||
<td>2013/03/16</td> | ||
<td>548.2154</td> | ||
</tr> | ||
<tr id="outerFirst"> | ||
<td>1</td> | ||
<td>test</td> | ||
<td>2005/10/24</td> | ||
<td>1.547</td> | ||
</tr> | ||
<tr> | ||
<td colspan="4"> | ||
<table class="table table-striped table-bordered sortable"> | ||
<thead> | ||
<tr> | ||
<th id="innerh1" data-defaultsort="asc">head1</th> | ||
<th>head2</th> | ||
<th>head3</th> | ||
<th>head4</th> | ||
</tr> | ||
</thead> | ||
<tbody id="inner"> | ||
<tr> | ||
<td>2</td> | ||
<td>hi</td> | ||
<td>2015/04/08</td> | ||
<td>5.234</td> | ||
</tr> | ||
<tr> | ||
<td>5</td> | ||
<td>yeah</td> | ||
<td>2013/03/16</td> | ||
<td>548.2154</td> | ||
</tr> | ||
<tr id="innerFirst"> | ||
<td>1</td> | ||
<td>test</td> | ||
<td>2005/10/24</td> | ||
<td>1.547</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
jasmine.getFixtures().fixturesPath = 'base/Tests/'; | ||
|
||
describe('Table inside table sorting', function() { | ||
beforeEach(function() { | ||
jasmine.getFixtures().load('tableInsideTable.html'); | ||
$.bootstrapSortable(); | ||
}); | ||
|
||
it("Outer table has correct order of rows", function() { | ||
var index = $('#outerFirst').index('#outer > tr'); | ||
expect(index).toBe(1); | ||
}); | ||
|
||
it("Inner table has correct order of rows", function() { | ||
var index = $('#innerFirst').index('#inner > tr'); | ||
expect(index).toBe(0); | ||
}); | ||
|
||
it("Inner table header keeps sorted class after outer sorting", function() { | ||
var innerHeader = $('#innerh1'); | ||
expect(innerHeader.hasClass('sorted')).toBe(true); | ||
|
||
$.bootstrapSortable({ sortingHeader: $('#outerh2') }); | ||
expect(innerHeader.hasClass('sorted')).toBe(true); | ||
}); | ||
|
||
it("Inner table header keeps sorted icon after outer sorting", function() { | ||
var innerHeader = $('#innerh1'); | ||
expect(innerHeader.children('.sign').length).toBe(1); | ||
|
||
$.bootstrapSortable({ sortingHeader: $('#outerh2') }); | ||
expect(innerHeader.children('.sign').length).toBe(1); | ||
}); | ||
}); |