GithubHelp home page GithubHelp logo

kenforthewin / react-redux-datatable Goto Github PK

View Code? Open in Web Editor NEW
72.0 6.0 10.0 983 KB

A React and Redux-based table for server-processed data.

Home Page: https://datatable.kenforthewin.com/

License: MIT License

JavaScript 98.26% HTML 1.74%
react redux

react-redux-datatable's Introduction

redux-remote-datatable

Test it out here. project example

Installation

npm i redux-remote-datatable --save

Usage

  • Add the reducer.
import { dataTableReducer } from 'redux-remote-datatable';

...

const appReducer = persistCombineReducers(config, {
  dataTableReducer,
  ...
});
  • Add the DataTableRedux component with its required initialization props.
import { DataTableRedux as DataTable } from 'redux-remote-datatable';

...

<DataTable
  fields={{"Name": "official_name", "Birthday": "birthday", "Thomas ID": "thomas_id" }}
  ajax="http://localhost:3000/legislators"
  idField="id" />

Initialization props

  • fields: An object whose keys are the table header titles and whose values correspond with values in the received data objects.
  • ajax: The data url.
  • idField: The unique identifier field of the received data objects. Used when assigning keys to child elements.

The component will make POST requests to the ajax endpoint for data to populate the table. In the body of the POST request will be a JSON object with the following parameters:

Request parameters

  • draw: starts at 1 and is incremented by 1 every time data is requested from the remote server and the table is re-drawn.
  • page: The current page.
  • perPage: The amount of data objects to be requested and displayed per page.
  • sortField: The field to sort the data by. Can be null.
  • sortDirection: One of asc and desc.
  • searchValue: The user-inputted search string. Default is a blank string.

Response parameters

  • draw: echo the draw from the request.
  • totalRecords: Record count before pagination.
  • data: An array of JSON objects with keys corresponding to the pre-defined fields.

Example response

{
    "draw": "1",
    "totalRecords": 473,
    "data": [
        {
            "id": 52,
            "official_name": "Roy Blunt",
            "thomas_id": "01464",
            "birthday": "1950-01-10"
        },
        {
            "id": 51,
            "official_name": "Richard Blumenthal",
            "thomas_id": "02076",
            "birthday": "1946-02-13"
        },
        ...
    ]
}

Example backend

  • An example backend, written in Ruby on Rails, is available here.
  • A separate example backend written in Elixir (Phoenix) here.

react-redux-datatable's People

Contributors

ken-nurelm avatar kenforthewin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-redux-datatable's Issues

Example or tutorial

Hi , it would be really cool if you provide an example code or more detailed documents . And perfectly would be a small tutorial on how to use the package and its functions . Thank you , please reply if you would do that ?

Bootstrap 4 support

Hi,

first of all thanks a lot for this project, I am very happy that I found it, it helps me a lot.
I would like to ask you something, mostly related to an experience that I don't have right now.

I have a project that works with Bootstrap4, so there is a "style conflict" if I use this library.
This is why, right now as a workaround, I have cloned the github project, removed the bootstrap 3 dependency from package.json and removed the "import bootstrap" statement from src/components/DataTable.js .

I have changed my package.json to include this local module (adding some grunt stuff).

Everything works just fine, but it's a workaround and it basically sucks.

Now the question: do you think is somehow possible / it makes sense to introduce the chance to specify the bootstrap version in the props? Or maybe (but I don't think it's a good solution, because bootstrap is needed) remove the bootstrap dependency and leave the bootstrap requirement to the developer, at a project level?

Help with sample code

Hi,

Could you please share your sample code developed for the demo, since we tried according to the readme but it is not working getting error like "e is undefined".

Thanks

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.