Skip to content

zdunecki/jaytable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jaytable

from json to table

##Usage

<script type="text/javascript" src="build/jaytable.min.js"></script>
var demo = new JayTable();

Build by JSON

demo.jay(jsonfile)

or with upload

<input type="file" id="jaytableFile"/>
<button id="createJayTable">Click</button>
var file = document.getElementById("jaytableFile");
var btn = document.getElementById("createJayTable");
demo.uploadjay(file,btn)

###Events

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)

About

from json to table

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors