Skip to content

make an dyadic array with colspan and rowspan from a tree, so you can easily display a table view to describe a tree structure.

License

Notifications You must be signed in to change notification settings

yuyangvi/tree2table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tree2table

===== make an dyadic array with colspan and rowspan from a tree, so you can easily display a table view to describe a tree structure. 这个模块是用来将一个任意的树形结构体转换成表格的工具。 它会计算出每个节点所需要的跨行跨列数,并将其按表格的要求格式生成二维数组。 Usage

npm install tree2table --save

example

var schema = {
  name: 'Sue',
  personal:{
    birthsday: '1871-02-05',
    gender: 'female',
    contact: {
      address: 'xxx street',
      zipcode: '100',
      mobile: '0141145114'
    }
  },
  education: {
    degree: 'Bachelor of Law',
    CA: 'Yale'
  }
};

var tree2table = require(tree2table);
var result = tree2table(schema);
console.log(result);

result

[ [ { trace: 'name', colspan: 3, rowspan: 1 } ],
  [ { trace: 'personal', colspan: 1, rowspan: 5 },
    { trace: 'birthsday', colspan: 2, rowspan: 1 } ],
  [ { trace: 'gender', colspan: 2, rowspan: 1 } ],
  [ { trace: 'contact', colspan: 1, rowspan: 3 },
    { trace: 'address', colspan: 1, rowspan: 1 } ],
  [ { trace: 'zipcode', colspan: 1, rowspan: 1 } ],
  [ { trace: 'mobile', colspan: 1, rowspan: 1 } ],
  [ { trace: 'education', colspan: 2, rowspan: 2 },
    { trace: 'degree', colspan: 1, rowspan: 1 } ],
  [ { trace: 'CA', colspan: 1, rowspan: 1 } ] ]

####at last you get this:

name
personalbirthday
gender
contactaddress
zipcode
mobile
educationdegree
CA

About

make an dyadic array with colspan and rowspan from a tree, so you can easily display a table view to describe a tree structure.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published