npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-table-builder

v1.1.8

Published

'react-table-builder' is a React component library that allows you to easily display tables with columns and fetch data from external sources. With react-json-table, you can create dynamic tables in your React applications by simply passing JSON data and

Downloads

5

Readme

react-table-builder

'react-table-builder' is a React component library that allows you to easily display tables with columns and fetch data from external sources. With react-json-table, you can create dynamic tables in your React applications by simply passing JSON data and column configuration.

'react-table-builder' is a React.js library for making life easy if you want to fetch data and display on table.

Installation

You can install react-json-table via npm:

npm install react-table-builder

Usage

To use react-table-builder, import the DynamicTable component into your React component and pass the JSON data and column configuration as props.

import DynamicTable from "react-table-builder";

function App() {
  const appData = {
    id: 1,
    title: "ContactUs Form Filled Data",
    isEditable: true,
    apiURL: "http://localhost:8081/contactus", // This URL will be used to fetch data from database
    multiRecords: true,
    pageSize: 10, // Page Size, if you want to add pagination, if not required, remove this key.
    srNo:true, // If you want Serial number at the starting of table
    data: [
      {
        id: 1,
        name: "firstName", // Column key name expecting from api responce
        displayName: "First Name", // Column name to be displayed
        displayOnTable: true, // If you want to display on table
        input: "text",
        isActive: true,
      },
      {
        id: 2,
        name: "lastName", 
        displayName: "Last Name",
        order: 2,
        editable: true,
        displayOnTable: true,
        input: "text",
        isActive: true,
        dataType: "String",
        required: "Please enter last name",
        isSearchable: true, // This field will be usefull for filtering column
      },
      {
        id: 3,
        name: "email",
        displayName: "Email",
        order: 3,
        editable: true,
        displayOnTable: true,
        input: "text",
        isActive: true,
        dataType: "String",
        required: "Email Address is required",
        pattern: {
          value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/, // This will be usefull in nearest future
          message: "Please Enter valid Email address",
        },
        isSearchable: true,
      },
      {
        id: 4,
        name: "phone",
        displayName: "Phone",
        order: 4,
        editable: true,
        displayOnTable: true,
        input: "text",
        isActive: true,
        dataType: "String",
        required: "Phone Number is required",
        isSearchable: true,
        pattern: /^\+?[0-9\s-]+$/,
      },
      {
        id: 5,
        name: "message",
        displayName: "Message",
        order: 5,
        editable: true,
        displayOnTable: false,
        input: "textarea",
        isActive: true,
        dataType: "String",
        required: "Please add some message here",
      },
    ]
};
return (
    <div className="App">
     <DynamicTable
        appData={appData}
        className="table"
        editClicked={(data) => console.log(data)} // If 'isEditable' set to true then this function will be called on click of edit button 
      />
    </div>
  );
}

Output

IMAGE_DESCRIPTION

Where all the data will be fetched from apiURL "http://localhost:8081/contactus" which is mentioned in appData.

Sample Response data

if pageSize is added any numeric value 'react-table-builder' will call apiURL as

http://localhost:8081/contactus/2/1 where 2 = no. of elements on 1 page & 1 = currunt page number

and below responce will be expected from api.

{"data":[{"_id":"65e99135ceabdf91793a3d20","firstName":"Harshita","lastName":"Narwade","email":"[email protected]","phone":"9187645679","message":"Sample New Message here","__v":0},{"_id":"65e9910aceabdf91793a3d1e","firstName":"Vishal","lastName":"Gaikwad","email":"[email protected]","phone":"9175129361","message":"Sample Message","__v":0}],"pagination":{"count":4,"perPage":"2","page":"1"}}