Skip to content

Commit 237915e

Browse files
author
Jessica Lord
authored
Merge pull request #7 from jlord/next
Next
2 parents 90eca3c + d7056b5 commit 237915e

File tree

9 files changed

+351
-236
lines changed

9 files changed

+351
-236
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
test/sheetsee.js

README.md

+53-78
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,65 @@
1-
# Sheetsee-tables
1+
[![Standard - JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
22

3-
see: [jlord.github.io/sheetsee.js](http://jlord.github.io/sheetsee.js)
4-
demo: [tables](http://jlord.github.io/sheetsee.js/demos/demo-table.html)
3+
# sheetsee-tables
54

6-
With this module you can create tables of your data that are sortable, searchable and paginate-able.
5+
Sheetsee,js uses this module to make tables. With this module you can create tables with your spreadsheet data that are sortable, searchable and paginate-able.
76

8-
You'll need a placeholder `<div>` in your html, a `<script>` mustache template and a `<script>` that initiates the table.
7+
You'll need a placeholder `<div>` in your html, a `<script>` with a [Mustache.js](https://mustache.github.io) template and a `<script>` that tells Sheetsee to build the table.
98

109
## Your HTML Placeholder
1110

12-
This is as simple as an empty `<div>` with an id.
11+
This is as simple as an empty `<div>` with an `id`.
1312

1413
## Your Template
1514

16-
Your template is the mockup of what you'd like your table to look like and what content it should show. The style is up to you! It is an HTML template inside of `<script>` tags. **The id of the template should be the same as the HTML placeholder it corresponds to but with "_template" on the end. Unless you're using one template, for multiple divs, in which case, you'll pass in the template name in the options of `makeTable()`**
15+
Your template is the mockup of what you'd like your table to look like and what content it should show. The style is up to you! It is a [mustache](https://mustache.github.io) template inside of `<script>` tags.
16+
17+
**The `id` of the template should be the same as the HTML placeholder it corresponds to but with "_template" on the end.**
1718

1819
### Sorting
1920

2021
If you want users to be able to click on headers and sort that column, your template must include table headers with the class `tHeader`.
2122

2223
You can then style `.tHeader` in your CSS to make them look how you want.
2324

25+
**You must also make the inner text of your table headers have the same capitalization as in your spreadsheet. It's ok to have spaces in your table header but don't use spaces in your spreadsheet headers.**
26+
27+
- Spreadsheet column name: 'PlaceName'
28+
- OK table header: 'Place Name'
29+
- Not OK table header: 'PLACENAME', 'placename'
30+
2431
## Your Script
2532

26-
You'll want to set your table options and pass them into `Sheetsee.makeTable()`. If you want to add a search/filter, pass your options into `Sheetsee.initiateTableFilter()`
33+
You'll want to set your table options and pass them into `Sheetsee.makeTable()`. If you want to add a search/filter, pass your options into `Sheetsee.initiateTableFilter()`.
34+
35+
## Methods
2736

28-
## Funtions
37+
Functions for you to use! There are just two, woo!
2938

30-
### Sheetsee.makeTable(tableOptions)
39+
### `Sheetsee.makeTable(tableOptions)`
3140

3241
You pass in an object containing:
3342

34-
- `data` your data array
35-
- `pagination` how many rows displayed at one time, defaults to all
36-
- `tableDiv` the <div> placeholder in your HTML
37-
- `filterDiv` the `<div>` containing your `<input>` filter if using search
38-
- `templateID` if you are reusing a template, use it's name here (if you don't include this, it will assume it matches `tableDiv` + `_template`)
43+
- `data` _array_ your data from Tabletop.js **required**
44+
- `pagination` _number_ how many rows displayed at one time, defaults to all
45+
- `tableDiv` _string_ the `<div>` `id` placeholder in your HTML, includes the hash `#` **required**
46+
- `filterDiv` _string_ the `<div>` `id` containing your `<input>` filter if using search, includes the hash `#` **required if using filter**
47+
- `templateID` _string_ the `id` of your `<script>` tag with the template, defaults to assume it's the same as `tableDiv` + `_template`.
3948

4049
```javascript
4150
var tableOptions = {
42-
"data": gData,
43-
"pagination": 10,
44-
"tableDiv": "#fullTable",
45-
"filterDiv": "#fullTableFilter",
46-
"templateID": "fullTable"
47-
}
51+
"data": data,
52+
"pagination": 10,
53+
"tableDiv": "#fullTable",
54+
"filterDiv": "#fullTableFilter",
55+
"templateID": "fullTable_template"
56+
}
4857
Sheetsee.makeTable(tableOptions)
4958
```
5059

5160
#### Pagination
5261

53-
If you do not put in a number for pagination, by default it will show all of the data at once. With pagination, HTML will be added at the bottom of your table for naviagtion, which you can style in your CSS:
62+
If you do not put in a number for pagination, by default it will show all of the data at once. With pagination, HTML will be added at the bottom of your table for navigation, which you can style in your CSS:
5463

5564
_HTML_
5665

@@ -64,42 +73,34 @@ _HTML_
6473
_CSS_
6574

6675
```CSS
67-
#Pagination {background: #eee;}
68-
.pagination-next, .pagination-pre {cursor: hand;}
69-
.no-pag {color: #acacac;}
76+
#Pagination {}
77+
.pagination-next {}
78+
.pagination-pre {}
79+
.no-pag {}
7080
```
7181

72-
## Table Filter/Search
82+
### `Sheetsee.initiateTableFilter(tableOptions)`
7383

74-
If you want to have an input to allow users to search/filter the data in the table, you'll add an input to your HTML. Give it an id and if you want, placeholder text:
84+
If you want to have an input to allow users to search/filter the data in the table, you'll add an input to your HTML. Give it an id and if you want add placeholder text. You'll also need to add a 'clear' button using the `.clear` CSS class.
7585

7686
```javascript
7787
<input id="tableFilter" type="text" placeholder="filter by.."></input>
88+
<a href="#" class=".clear">Clear</a>
7889
```
7990

80-
### Sheetsee.initiateTableFilter(tableOptions)
81-
82-
You will then call this function with your `tableOptions` to make that input live and connected to your table:
91+
Then you'll pass your `tableOptions` object into this method:
8392

8493
```javascript
8594
Sheetsee.initiateTableFilter(tableOptions)
8695
```
8796

88-
It will connect that input to your data as well as inject this HTML for a button, which you can style yourself in your CSS:
89-
90-
91-
```HTML
92-
<span class="clear button">Clear</span>
93-
<span class="noMatches">no matches</span>
94-
```
95-
9697
## Example
9798

9899
_HTML_
99100

100101
```HTML
102+
<input id="siteTableFilter" type="text"></input><a href="#" class=".clear">Clear</a>
101103
<div id="siteTable"></div>
102-
<input id="siteTableFilter" type="text"></input>
103104
```
104105

105106
_Template_
@@ -119,45 +120,19 @@ _JavaScript_
119120

120121
```javascript
121122
<script type="text/javascript">
122-
document.addEventListener('DOMContentLoaded', function() {
123-
var tableOptions = {
124-
"data": gData,
125-
"pagination": 10,
126-
"tableDiv": "#siteTable",
127-
"filterDiv": "#siteTableFilter",
128-
"templateID": "tableTemplate"
129-
}
130-
Sheetsee.makeTable(tableOptions)
131-
Sheetsee.initiateTableFilter(tableOptions)
132-
})
123+
document.addEventListener('DOMContentLoaded', function() {
124+
var tableOptions = {
125+
"data": data,
126+
"pagination": 10,
127+
"tableDiv": "#siteTable",
128+
"filterDiv": "#siteTableFilter",
129+
"templateID": "siteTable_template"
130+
}
131+
Sheetsee.makeTable(tableOptions)
132+
Sheetsee.initiateTableFilter(tableOptions)
133+
})
133134
</script>
134135
```
135136

136-
To create another table, simply repeat the steps above (abreviated here below).
137-
138-
_HTML_
139-
```HTML
140-
<div id="secondTable"></div>
141-
<input id="secondFilter" type="text"></input>
142-
```
143-
_Template_
144-
145-
```JavaScript
146-
<script text="text/javascript" id="secondTable">
147-
// Template here
148-
</script>
149-
```
150-
151-
_JavaScript_
152-
153-
```JavaScript
154-
<script>
155-
var secondTableOpts = {} // the options
156-
Sheetsee.makeTable(secondTableOpts)
157-
Sheetsee.initiateTableFilter(secondTableOpts)
158-
</script>
159-
```
160-
161-
Learn more about the things you can do with [ICanHaz.js](http://icanhazjs.com).
162-
163-
_[View Demo](/demos/demo-table.html)_
137+
_[View Demo](http://jlord.us/sheetsee.js/demos/demo-table.html)_
138+
_[Visit Site](http://jlord.us/sheetsee.js)_

0 commit comments

Comments
 (0)