Skip to content

Commit

Permalink
Implemented sort
Browse files Browse the repository at this point in the history
  • Loading branch information
viskin committed Apr 25, 2015
1 parent d03105b commit 0a0e3f8
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 45 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Implemented
- CRUD operations on DataSource are synced with PouchDB when sync method is called.
- Tests for implemented functionality.
- Support for PouchDB Collate in _id.
- Implement sorting.

In progress
- Implement paging.
Expand Down Expand Up @@ -73,9 +74,7 @@ var dataSource = new kendo.data.PouchableDataSource({
transport: {
pouchdb: {
db: db,
idFactory: function (data) { //This can be just string
return data.ProductID;
}
idField: "ProductID"
}
});
```
Expand All @@ -93,7 +92,7 @@ schema: {
```
_id will be created by applying [pouchCollate.toIndexableString](<https://github.com/pouchdb/collate/#toindexablestringobj>)
to data provided by idFactory, so data will be stored sorted by model id, either it string or numeric type.
to data provided by idField, so data will be stored sorted by model id, either it string or numeric type.
## id field
Expand Down Expand Up @@ -121,21 +120,23 @@ For sort to work, appropriate view should be provided for each field that will b
```js
var dataSource = new kendo.data.PouchableDataSource({
type: "pouchdb",
sort: { field: "name", dir: "asc"},
transport: {
pouchdb: {
db: db,
idFactory: "passport",
idField: "passport",
fieldViews: {
"name: "sortIndex/byName",
"age,name" : "sortIndex/byAgeName"
"age" : "sortIndex/byAge"
}
}
});
//Now you can sort by name
```
Exception will be thrown if trying to sort by field that has no index.
Exception will be thrown if trying to sort by field that has no index. Exception will be thrown if trying to sort by
multiple columns, this functionality is not supported.
Of course, the _id field can be sorted by without providing view for it.
Expand Down
4 changes: 1 addition & 3 deletions demo/kendo-pouchdb-grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
transport: {
pouchdb: {
db: db,
idFactory: function (data) {
return data.ProductID;
}
idField: "ProductID"
}
},
//batch: true, //TODO
Expand Down
2 changes: 1 addition & 1 deletion dist/kendo-pouchdb.amd.min.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* kendo-pouchdb.amd v0.0.1 20-04-2015 (C) 2015 Terikon Software */
/* kendo-pouchdb.amd v0.0.1 25-04-2015 (C) 2015 Terikon Software */
define(["kendo","kendo-pouchdb"],function(a){"use strict";return a});
4 changes: 2 additions & 2 deletions dist/kendo-pouchdb.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/kendo-pouchdb.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0a0e3f8

Please sign in to comment.