New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-material-dynamic-data-table

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-material-dynamic-data-table

This is a React component developed based on material ui.

latest
npmnpm
Version
0.2.6
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

React Material Dynamic Data Table

This is a React component developed based on material ui.

Features

  • Pagination
  • Filters
    • string, number, date, date range
    • Static dropdown
    • Dynamic dropdown
    • Multi Select
    • Reset Filters

Installation

npm i --save react-material-dynamic-data-table

Usage

App.js

import Datatable from 'react-material-dynamic-data-table/dist';
import Service from './service';

function App() {
  const propertys = [
    {key: "employee_id", value: "Employee ID", search: {type: 'string'}},
    {key: "created_date", value: "Created Date", search: {type: 'date-range'}},
    {key: "age", value: "Age", search: {type: 'number'}},
    {key: "city", value: "City", search: {type: 'dropdown',value:"city_id", label: "city_name", api: (new Service()).citysData}},
    {key: "gender", value: "Gender", search: {type: 'select', options:[{value:'male', label:'Male'},{value:'female', label: 'Female'}]}}
];

  return (
      <div>
          <Datatable propertys={propertys} api={(new Service()).getAllData} search={true} />
      </div>
  );
}

export default App;

service.js

import axios from 'axios';

export default class Service {
    api = "http://your-domain-name/";
    
    /*
        this function is used to get all grid data.
        @parms start int (start page number)
        @parms limit int (records per page)
        @parms search object (it is a object contains search information)
        @returns callback(status, rows, totalRecords) if status false send error
    */
    getAllData = (start, limit, search, callback) => {
        axios.post(this.api+'getAll', {"start": start*limit, "length": limit, "search": search}) 
        .then(function(data) {
            callback(true, data.data.data, data.data.totalRecords);
        })
        .catch(function(err) {
            callback(false, err, 0);
        });
    }

    /*
        this function is used to get dropdown information
        @returns callback(status, rows) - if status false send error
    */
    citysData = (callback) => {
        axios.get(this.api+'getCitys')
        .then(function(data) {
            callback(true, data.data.data);
        })
        .catch(function(err) {
            callback(false, err);
        });
    }
}

props send to component

Propdata typeDescription
searchbooleanif it true show the search block else not.
apifunctionPass function Referance. This function should be like this -- APIFunctionName(start, limit, search, callback)
propertysarray of objectscheck below keys are the property object keys.

Propertys Object

Propdata typeDescription
keystringResponse Json Keys Place Here
valuestringThis is a display label
search(optional)Search Objectif it is not set Search is not applied for this key

Search Object

Propdata typeDescription
typeENUM(string, number, date, date-range, dropdown, select)
valuestringif type is dropdown you have to pass value to use in dropdown
labelstringif type is dropdown you have to pass value to show in dropdown
apifunctionPass function Referance. This function should be like this -- DropdownFunctionName(callback).
optionsarray of objectseach object contains label and value

API Referance Function Perameters

keydata typeDescription
startnumberthis is page number - page number starts from 0
limitnumberHowmany records show in a page
searchobjectthis is a dynamic object. this is constructed based on key in properts object
callbackfunctioncallback(status: boolean, data: [Objects], totalRecords: number) -- if status false send data empty([]) and totalRecords is Zero(0).

Dropdown Referance Function Perameters

keydata typeDescription
callbackfunctioncallback(status: boolean, data: [Objects]) -- if status false send data empty([]).

License

MIT

Keywords

react js

FAQs

Package last updated on 13 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts