Skip to content

Commit

Permalink
Version 0.5.0.
Browse files Browse the repository at this point in the history
Store data in template instance instead of session.
All settings can be named arguments or part of settings argument.
New setting to add an id to the table.
Remove group argument for sharing state between tables.
  • Loading branch information
aslagle committed Oct 26, 2014
1 parent 4ad277e commit d1a8cbf
Show file tree
Hide file tree
Showing 24 changed files with 524 additions and 487 deletions.
62 changes: 36 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ If you're updating to Meteor 0.8.0, note that reactiveTable is now a template wi
- [Quick Start](#quick-start)
- [Customization](#customization)
- [Settings](#settings)
- [rowClass Examples](#rowclass-examples)
- [Settings Object](#settings-object)
- [Styling](#styling)
- [Setting columns](#setting-columns)
- [Setting column headers](#setting-column-headers)
Expand All @@ -40,27 +42,21 @@ This package adds a template called reactiveTable. Create and subscribe to a col

When the whole collection should be in the table, it's best to pass in the Meteor collection object (returned by new Meteor.Collection()). You can also pass in the cursor returned by collection.find() to show a subset of the collection, or a plain array to show data that's not in a Meteor collection.



## Customization

The reactiveTable helper accepts an additional settings argument that can be used to configure the table.

{{> reactiveTable collection=collection settings=settings}}

Define the settings in a helper for the template that calls reactiveTable:
If you're new to Meteor, note that global variables aren't available from templates. You can add template helpers to access them:

Template.myTemplate.helpers({
settings: function () {
return {
rowsPerPage: 10,
showFilter: true,
fields: ['name', 'location', 'year']
};
myCollection: function () {
return myCollection;
}
});


## Customization

The reactiveTable helper accepts additional arguments that can be used to configure the table.

{{> reactiveTable collection=collection showNavigation='never' rowsPerPage=5}}

### Settings

* `showFilter`: Boolean. Whether to display the filter box above the table. Default `true`.
Expand All @@ -70,6 +66,8 @@ Define the settings in a helper for the template that calls reactiveTable:
* `fields`: Object. Controls the columns; see below.
* `showColumnToggles`: Boolean. Adds a button to the top right that allows the user to toggle which columns are displayed. Add `hidden` to fields to hide them unless toggled on, see below. Default `false`.
* `useFontAwesome`: Boolean. Whether to use [Font Awesome](http://fortawesome.github.io/Font-Awesome/) for icons. Requires the `font-awesome` package to be installed. Default `false`.
* `class`: String. Classes to add to the table element in addition to 'reactive-table'. Default: 'table table-striped table-hover'.
* `id`: String. Unique id to add to the table element. Default: generated with [_.uniqueId](http://underscorejs.org/#uniqueId).
* `rowClass`: String or function returning a class name. The row element will be passed as first parameter.

#### rowClass examples
Expand Down Expand Up @@ -98,6 +96,29 @@ as a string
rowClass: 'danger',
```

#### Settings Object

Settings can also be grouped into a single object to pass to the table:

{{> reactiveTable settings=settings}}

Define the settings in a helper for the template that calls reactiveTable:

Template.myTemplate.helpers({
settings: function () {
return {
collection: collection,
rowsPerPage: 10,
showFilter: true,
fields: ['name', 'location', 'year']
};
}
});

You can continue to pass some settings as named arguments while grouping the others into the settings object:

{{> reactiveTable collection=collection fields=fields settings=settings}}

### Styling

Add bootstrap or bootstrap-3 to style the table, or add your own css. The generated table will have the class 'reactive-table'. To use [Font Awesome](http://fortawesome.github.io/Font-Awesome/) for icons, also add the font-awesome package and set `useFontAwesome` to `true` in the settings.
Expand Down Expand Up @@ -206,17 +227,6 @@ Template.posts.events({
});
```

## Multiple tables

When multiple tables are used in the same application, by default they'll share pagination settings and filters. Add a different group to each table's settings to allow separate table state.

{
fields: [...],
group: 'resources'
}

The default group is 'reactive-table'.

## Internationalization

Internationalization support is provided using [just-i18n](https://github.com/subhog/meteor-just-i18n).
Expand Down
1 change: 1 addition & 0 deletions examples/leaderboard/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
2 changes: 2 additions & 0 deletions examples/leaderboard/.meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
2 changes: 1 addition & 1 deletion examples/leaderboard/.meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[email protected].3
[email protected].4
108 changes: 54 additions & 54 deletions examples/leaderboard/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
anti:[email protected]
[email protected].2
aslagle:reactive-table@0.4.10
[email protected].0
[email protected].1
[email protected].0
[email protected].0
[email protected].0
[email protected].1
[email protected].0
[email protected].0
[email protected].1
[email protected].3
[email protected].1
[email protected].9
[email protected].4
[email protected].3
[email protected].0
[email protected].1
[email protected].0
[email protected].1
[email protected].1
[email protected].6
[email protected].0
[email protected].0
[email protected].0
[email protected].0
[email protected].10
[email protected].3
[email protected].1
[email protected].1
[email protected].0
[email protected].3
mizzao:[email protected].0
[email protected].0
[email protected].6
[email protected].3
aslagle:reactive-table@0.5.0
[email protected].1
[email protected].2
[email protected].1
[email protected].1
[email protected].1
[email protected].2
[email protected].1
[email protected].1
[email protected].2
[email protected].4
[email protected].2
[email protected].10
[email protected].5
[email protected].4
[email protected].1
[email protected].2
[email protected].1
[email protected].2
[email protected].2
[email protected].7
[email protected].1
[email protected].1
[email protected].1
[email protected].1
[email protected].11
[email protected].4
[email protected].2
[email protected].2
[email protected].1
[email protected].4
mizzao:[email protected].0_1
[email protected].1
[email protected].7
natestrauser:[email protected]
[email protected].2
[email protected].0
[email protected].0
[email protected].3
[email protected].2
[email protected].0
[email protected].0
[email protected].1
[email protected].2
[email protected].2
[email protected].2
[email protected].2
[email protected].7
[email protected].2
[email protected].3
[email protected].0
[email protected].0
[email protected].0
[email protected].2
[email protected].3
[email protected].1
[email protected].1
[email protected].4
[email protected].3
[email protected].1
[email protected].1
[email protected].2
[email protected].3
[email protected].3
[email protected].3
[email protected].3
[email protected].8
[email protected].3
[email protected].4
[email protected].1
[email protected].1
[email protected].1
[email protected].3
2 changes: 1 addition & 1 deletion examples/leaderboard/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (Meteor.isClient) {
fields: [
{ key: 'name', label: 'Full Name' },
{ key: 'name', label: 'First Name', fn: function (name) { return name.split(' ')[0]; } },
{ key: 'score', label: 'Score'}
{ key: 'score', label: 'Score' }
],
useFontAwesome: true
};
Expand Down
1 change: 1 addition & 0 deletions examples/table-features/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
2 changes: 2 additions & 0 deletions examples/table-features/.meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
2 changes: 1 addition & 1 deletion examples/table-features/.meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[email protected].3
[email protected].4
106 changes: 53 additions & 53 deletions examples/table-features/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
anti:[email protected]
[email protected].2
aslagle:reactive-table@0.4.10
[email protected].0
[email protected].1
[email protected].0
[email protected].0
[email protected].0
[email protected].1
[email protected].0
[email protected].0
[email protected].1
[email protected].3
[email protected].1
[email protected].9
[email protected].4
[email protected].3
[email protected].0
[email protected].1
[email protected].0
[email protected].1
[email protected].1
[email protected].6
[email protected].0
[email protected].0
[email protected].0
[email protected].10
[email protected].3
[email protected].1
[email protected].1
[email protected].0
[email protected].3
mizzao:[email protected].0
[email protected].0
[email protected].6
[email protected].2
[email protected].0
[email protected].0
[email protected].3
[email protected].2
[email protected].0
[email protected].0
[email protected].1
[email protected].2
[email protected].2
[email protected].2
[email protected].2
[email protected].7
[email protected].2
[email protected].3
[email protected].0
[email protected].0
[email protected].0
[email protected].2
[email protected].3
aslagle:reactive-table@0.5.0
[email protected].1
[email protected].2
[email protected].1
[email protected].1
[email protected].1
[email protected].2
[email protected].1
[email protected].1
[email protected].2
[email protected].4
[email protected].2
[email protected].10
[email protected].5
[email protected].4
[email protected].1
[email protected].2
[email protected].1
[email protected].2
[email protected].2
[email protected].7
[email protected].1
[email protected].1
[email protected].1
[email protected].11
[email protected].4
[email protected].2
[email protected].2
[email protected].1
[email protected].4
mizzao:[email protected].0_1
[email protected].1
[email protected].7
[email protected].3
[email protected].1
[email protected].1
[email protected].4
[email protected].3
[email protected].1
[email protected].1
[email protected].2
[email protected].3
[email protected].3
[email protected].3
[email protected].3
[email protected].8
[email protected].3
[email protected].4
[email protected].1
[email protected].1
[email protected].1
[email protected].3
Loading

0 comments on commit d1a8cbf

Please sign in to comment.