0.0.18 • Published 3 years ago

@terguevarra/react-bootstrap-treeview v0.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React Bootstrap Treeview

Installation

  1. Install Package
npm install --save @terguevarra/react-bootstrap-treeview
  1. Include Bootstrap 5 and Bootstrap Icons

Via CDN:

<link   href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" 
        rel="stylesheet" />

<link   href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css"
        rel="stylesheet" />

or

Import Bootstrap 5 and Bootstrap Icons:

npm install bootstrap@next bootstrap-icons

Usage

import React, { useState } from 'react';
import ReactBootstrapTreeview from '@terguevarra/react-bootstrap-treeview';

const sampleData = [
  {
    "id": 1,
    "parentId": 0,
    "label": "Lorem Ipsum"
  },
  {
    "id": 2,
    "parentId": 0,
    "label": "Lorem Ipsum"
  },
  {
    "id": 3,
    "parentId": 1,
    "label": "Lorem Ipsum"
  },
  {
    "id": 4,
    "parentId": 2,
    "label": "Lorem Ipsum"
  },
  {
    "id": 5,
    "parentId": 3,
    "label": "Lorem Ipsum"
  }
]

function App(){
    const [data, setData] = useState(sampleData);

    return(
        <>
            <ReactBootstrapTreeview list={data}
                                    idName="id"
                                    parentIdName="parentId"
                                    label={rowData => `${rowData.id} - ${rowData.label}`} />
        </>
    );
}

export default App;

Main Props

NameTypeDefault ValueRequiredDescription
listArray-YesData to be rendered
idNameString-YesProperty name of unique identification
parentIdNameString-YesProperty name of Parent Id
labelString or Function-YesProperty to be rendered
tableClassNameStringtableNoBootstrap Table class you want to use for the treeview
actionsArray-NoActions list. You can add buttons to rows.

actions

NameTypeDefault ValueRequiredDescription
iconString-YesBootstrap Icon class (eg. bi bi-plus)
onClickFunction-YesThis will trigger the function on button click. (Parameters: event, rowData)
buttonClassStringbtnNoBootstrap button class (eg. btn btn-primary)
disabledboolfalseNoButton is enabled or disabled
hiddenboolfalseNoButton is visible or not
0.0.18

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago