Skip to content

Commit

Permalink
added ability to disable sortingDirection
Browse files Browse the repository at this point in the history
  • Loading branch information
grese committed Mar 9, 2015
1 parent 6097a4a commit f3ba034
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ You'll need to include the following files in your project:
* loadMoreAction: "[Action Name]" *// (the action that should be fired when user scrolls to bottom of page - only used when infiniteScrollEnabled is true, and isLoadingRows is false)*
* noContentView: [Instance of Em.View] *// (this view will be rendered instead of the table if there are no rows.)*
* useRenderingIndicator: (true || false) *// (True by default. When true, this will disable the adding of a rendering indicator to the table when the table is taking a while to render)*
* disableSortDirection: (true || false) *// (False by default.) When true, the sortAscending property will not change when the user clicks a column header (The sortAscending property will remain unchanged)*

#### Column Configurations:
Here are the options for configuring columns:
Expand Down Expand Up @@ -121,5 +122,7 @@ export default Ember.Controller.extend({
isLoadingRows=isLoadingData
loadMoreAction='loadMore'
customSortAction='sortTheTable'
sortAscending=false
disableSortDirection=false
}}
```
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-bootstrap-table",
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/grese/ember-bootstrap-table",
"authors": [
"grese <[email protected]>"
Expand Down
14 changes: 9 additions & 5 deletions dist/ember-bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@

var TFootContainerView = Em.ContainerView.extend({
init: function(){
this.set('loadingRow', LoadingRow.create());
this._super();
this.set('loadingRow', LoadingRow.create());
this.pushObject(this.get('loadingRow'));
},
tagName: 'tfoot',
childViews: ['loadingRow'],
loadingRow: null,
component: function(){
return this.get('_parentView.component');
Expand All @@ -350,15 +350,15 @@

var TableContainerView = Em.ContainerView.extend({
init: function(){
this._super();
this.setProperties({
thead: THeadContainerView.create(),
tbody: TBodyContainerView.create(),
tfoot: TFootContainerView.create()
});
this._super();
this.pushObjects([this.get('thead'), this.get('tbody'), this.get('tfoot')]);
},
tagName: 'table',
childViews: ['thead', 'tbody', 'tfoot'],
classNames: ['table-component-table', 'table'],
component: function(){
return this.get('_parentView._parentView');
Expand Down Expand Up @@ -416,6 +416,7 @@
infiniteScrollEnabled: false,
isLoadingRows: false,
loadMoreAction: null,
disableSortDirection: false,
// [END] User-Defined Options:


Expand Down Expand Up @@ -558,7 +559,10 @@
_sortTable: function(colIdx){
// If the colIdx is same as current sortIndex, reverse sorting order.
if(colIdx === this.get('sortIndex')){
this.set('sortAscending', !this.get('sortAscending'));
// If disableSortDirection is false, we update sortAscending. If not, do nothing.
if(!this.get('disableSortDirection')){
this.set('sortAscending', !this.get('sortAscending'));
}
}else{
this.set('sortIndex', colIdx);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/ember-bootstrap-table.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-bootstrap-table",
"version": "0.1.0",
"version": "0.1.1",
"description": "An Ember Component for creating dynamic bootstrap tables.",
"repository": {
"type": "git",
Expand Down
6 changes: 5 additions & 1 deletion src/javascript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@
infiniteScrollEnabled: false,
isLoadingRows: false,
loadMoreAction: null,
disableSortDirection: false,
// [END] User-Defined Options:


Expand Down Expand Up @@ -558,7 +559,10 @@
_sortTable: function(colIdx){
// If the colIdx is same as current sortIndex, reverse sorting order.
if(colIdx === this.get('sortIndex')){
this.set('sortAscending', !this.get('sortAscending'));
// If disableSortDirection is false, we update sortAscending. If not, do nothing.
if(!this.get('disableSortDirection')){
this.set('sortAscending', !this.get('sortAscending'));
}
}else{
this.set('sortIndex', colIdx);
}
Expand Down

0 comments on commit f3ba034

Please sign in to comment.