Coder Social home page Coder Social logo

react-treegrid's Introduction

React-GridTree

React GridTree is a react component built to easily render a table showing the properties of objects in a tree structure.

Check out the example project and the live demo

Installation

npm install react-gridtree

Usage

Example:

<GridTree
	data={[
		{
			name: "item 1"
			qty: 2,
			children: [
				{
					name: "item 1.1",
					qty: 1
				}
			]
		},
		{
			name: "item 2",
			qty: 4
		}
	]}
	options={{
		fields: [
			{ 
				property: 'name',
				displayName: 'Name',
				width: '70%' 
			},
			{
				property: 'qty',
				displayName: 'Quantity',
				format: (value) => value.toFixed(2)
			}
		]
	}}
/>

Notes:

  • Styling not yet supported
  • The children attribute is reserved for the objects that will be shown inside the parent

Props

data Data to be displayed. Should be an array of objects. Each object's children property should be an array of nested objects.

data = [
	{
		name: "item 1"
		qty: 2,
		children: [
			{
			name: "item 1.1",
			qty: 1
			}
		]
	},
	{
		name: "item 2",
		qty: 4
	}
]

options Object that can contain the properties:

  • fields - Required fields should be an array containing one object for each data property that should be displayed. This object can have the properties:

  • property - Required The name of the data property (e.g. "name")

  • displayName - Required The text to be shown on the table header (e.g. "Name")

  • width The width of the column (e.g. "50%")

  • format A function that receives the data value, and returns a formatted text to be shown (e.g. (value) => value.toFixed(2)

options = {
	fields: [
		{ 
			property: 'name',
			displayName: 'Name',
			width: '70%' 
		},
		{
			property: 'qty',
			displayName: 'Quantity',
			format: (value) => value.toFixed(2)
		}
	]
}

react-treegrid's People

Contributors

phillbeck avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.