Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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
```html

Click
```
```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)