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

stark-custom-datatable-next

v1.1.2

Published

**Customizable datatable for react**

Downloads

85

Readme

Custom Datatable

Customizable datatable for react

Create customizable datatable

Installation

npm i stark-custom-datatable-next

Demo

alt text

Usage

Import this component in page where you want to display table content.

import CustomTable from "stark-custom-datatable-next";
import 'bootstrap/dist/css/bootstrap.min.css';
// some code

const rowData = [
    { id: 1, name: 'Sample name', email: '[email protected]', rowClass:'bgred' },
    { id: 2, name: 'Sample name', email: '[email protected]' },
    { id: 3, name: 'Sample name', email: '[email protected]' },
    { id: 4, name: 'Sample name', email: '[email protected]' },
  ]

// some code

render() {
    return (
        <>
        <CustomTable
        // role (optional:number) : Current user role for role wise column show
        role={1}
        // columns (required:array) : dispay column , id and label compulsory and one row column with 'id' key required  
        columns={[
          { id: 'id', label: 'Id', roleAccess: [1], isDisplay: true, columnRender: (col => (<span style={{ fontWeight: 'bold' }}>{col.label}</span>)), render: (row) => { return (<b>{row.name}</b>) } },
          { id: 'name', label: 'Name', roleAccess: [1] },
          { id: 'email', label: 'Email', roleAccess: [3], classes:'bgGray' },
        ]}
        // rows (required:array) : display row data of column
        rows={rowData}
        // tableClass (optional:String) : to override class of the table
        tableClass="table-striped"
        // tableContainerClass (optional:String) : to override class of the table wrapper
        tableContainerClass=""
        // dropdownContainerClass (optional:String) : to override class of the dropdown wrapper
        dropdownContainerClass=""
        // bulkActions (optional:array) : to add action on table
        bulkActions={[
          {
            actionTitle: 'Change Status',
            actionCallback: (e) => { console.log(e) },
          },
          {
            actionTitle: 'Delete',
            actionCallback: (e) => { console.log(e) },
          }
        ]}
        // showCheckbox (optional:boolean) : to show checkbox as first column
        showCheckbox={true}
        // showPagination (optional:boolean) : to show pagination of table
        showPagination={true}
        // paginationProps (optional:Object) : to display page number based on this props
        paginationProps={{
          totalItems: 5,
          itemsPerPage: 5,
          activePage: 1, //currentPage
          onPageChange:{(changedPage) => {
            console.log(changedPage);
          }}
        }}
        // selectedRowItems (optional:array) : to show selected row in table
        selectedRowItems={[4]}
        // onSelectRowsIndexes (optional:callback) : callback to get selected row ids
        onSelectRowsIndexes={(indexes) => {
          console.log('indexes', indexes); // eslint-disable-line
        }}
        // emptyRender (optional:callback) : callback to override empty table caption
        emptyRender={() => <h4>Data not exist</h4>}
        // emptyRender (optional:String) : override label of action button
        bulkActionsLabel="Apply"
      />
        </>
    )
}

column config

  • id (required:number)
  • labal (required:String)
  • classes (optional:String)
  • roleAccess (optional:Array) - if empty then this column will be visible to all user role. if roles are given then it will be column visible to that specifed roles
  • isDisplay (optional:Boolean) - hide or show column
  • columnRender (optional:callback) - to override column structure of specific column
  • render (optional:callback) - to override data structure of specific column

bulkActions config

  • actionTitle (required:String) - to display in action dropdown
  • actionCallback (required:callback) - callback when action trigger which return selected row id from table

paginationProps config

  • totalItems (required:Number) - total count of record for pagination
  • itemsPerPage (required:Number) - to dispay no of record per page
  • activePage (required:Number) - to check current page number
  • onPageChange (optional: callback) - to get current page selected

dependencies package

  • react-bootstrap
  • bootstrap
  • react-js-pagination
  • react-notifications
  • sweetalert