diff --git a/README.md b/README.md index c75589d8..fef42f7a 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,11 @@ users to filter and limit the data displayed within a long table. By default, th * Extended keyboard navigation ([ezEditTable](http://codecanyon.net/item/ezedittable-enhance-html-tables/2425123?ref=koalyptus) extension) * Inline cell or row editing ([ezEditTable](http://codecanyon.net/item/ezedittable-enhance-html-tables/2425123?ref=koalyptus) extension) * Row insertion or deleting ([ezEditTable](http://codecanyon.net/item/ezedittable-enhance-html-tables/2425123?ref=koalyptus) extension) - * And even more behaviors... + * And even more features... * Attach to an existing HTML table * Integration with any server-side technology as this is a pure client-side solution -* Callbacks for all events, and delegates for most actions -* Exhaustive documentation and API +* Exhaustive documentation and poweful API ## Getting started * Clone the repo using Git: diff --git a/package.json b/package.json index 446094f4..adb6b8e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tablefilter", - "version": "0.2.10", + "version": "0.2.11", "description": "A Javascript library making HTML tables filterable and a bit more", "license": "MIT", "author": { diff --git a/src/extensions/sort/sort.js b/src/extensions/sort/sort.js index 8ccf0012..3676491f 100644 --- a/src/extensions/sort/sort.js +++ b/src/extensions/sort/sort.js @@ -1,4 +1,3 @@ -// import 'script!sortabletable'; import AdapterSortableTable from './adapterSortabletable'; if(!window.SortableTable){ diff --git a/src/modules/state.js b/src/modules/state.js index 028e2e09..789e7322 100644 --- a/src/modules/state.js +++ b/src/modules/state.js @@ -33,12 +33,14 @@ export class State extends Feature { this.persistFilters = cfg.filters === false ? false : true; this.persistPageNumber = Boolean(cfg.page_number); this.persistPageLength = Boolean(cfg.page_length); + this.persistSort = Boolean(cfg.sort); this.cookieDuration = !isNaN(cfg.cookie_duration) ? parseInt(cfg.cookie_duration, 10) : 87600; this.hash = null; this.pageNb = null; this.pageLength = null; + this.sortIndex = null; this.state = {}; this.prfxCol = 'col_'; @@ -59,6 +61,8 @@ export class State extends Feature { (tf, pageNb) => this.updatePage(pageNb)); this.emitter.on(['after-page-length-change'], (tf, index) => this.updatePageLength(index)); + this.emitter.on(['column-sorted'], + (tf, index) => this.updateSort(index)); if (this.enableHash) { this.hash = new Hash(this); @@ -115,6 +119,10 @@ export class State extends Feature { } } + if(this.persistSort){ + let key = `${this.prfxCol}${this.sortIndex}`; + } + this.emitter.emit('state-changed', tf, this.state); } @@ -138,6 +146,11 @@ export class State extends Feature { this.update(); } + updateSort(index){ + this.sortIndex = index; + this.update(); + } + /** * Override state field * @@ -209,6 +222,8 @@ export class State extends Feature { (tf, pageNb) => this.updatePage(pageNb)); this.emitter.off(['after-page-length-change'], (tf, index) => this.updatePageLength(index)); + this.emitter.off(['column-sorted'], + (tf, index) => this.updateSort(index)); if (this.enableHash) { this.hash.destroy();