Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zdunecki/jaytable
from json to table
https://github.com/zdunecki/jaytable
Last synced: 14 days ago
JSON representation
from json to table
- Host: GitHub
- URL: https://github.com/zdunecki/jaytable
- Owner: zdunecki
- Created: 2016-07-28T17:26:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-07-28T23:23:35.000Z (over 8 years ago)
- Last Synced: 2024-05-02T05:13:15.487Z (8 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jaytable
from json to table##Usage
```javascript
var demo = new JayTable();
```
### Build by JSON```javascript
demo.jay(jsonfile)
```
### or with upload
```htmlClick
```
```javascript
var file = document.getElementById("jaytableFile");
var btn = document.getElementById("createJayTable");
demo.uploadjay(file,btn)
```###Events
```javascript
demo.on('uploadsuccess',function(event,data){
//some stuff on upload success
});demo.on('uploadfailure',function(event){
//some stuff on upload fail
});demo.on('jaysuccess',function(event,data){
//some stuff on success convert json
});demo.on('jayfailure',function(event){
//some stuff on fail convert json
});
```
###### JSON as table
```
{
"titles": [ <----- ---- it's our thead
[ <----- ---- need one array for thead tr element
{ <------------------------| Ob.A1
"title": "JayTableA" 1 |
}, |------ each object return td element for thead.
{ 2 | Ob.A2 title is our key for td elements
"title": "JayTableB" |
} <------------------------|
]
],
"elements": [ <-------- it's our tbody
{ <-------------------------------| Ob.B1
"columns": [ |
{ Ob.B1C1 |
"row":"JayTable is Awesome" |
}, |------ each object return tr element
{ Ob.B1C2 | for example it's our first tr
"row":"JayTable is Awesome!" |
} |
] |
},<--------------------------------|
{ <--------------------------------- Ob.B2 there is our next tr element
"columns": [
{<--------------------------------| Ob.B2C1
"row":"JayTable is Awesome 2" 1|
}, |------- each objects return tbody td elements
{ | Ob.B2C2
"row":"JayTable is Awesome 2!" 2|
}<--------------------------------|
]
}
]
}
```## Specification
* Must return only 2 main array's like titles,elements (look at top)
* First and second array like titles and elements (look at top) must return ONE array
* Each objects return one element, you can't pass few element's for one object
* Ob.A1, Ob.A2 .. Ob.A(n) return tr for thead (look at top)
* Ob.B1, Ob.B2 .. Ob.B(n) return tr for tbody (look at top)
* Ob.B1C1, Ob.B2C1 ..Ob.B(n)C(n) return td for tr-tbody (look at top)
* Each key for one element **must have** the same name
* You have free namespaces for all elements: **titles,title,elements,columns,rows** (look at top)