Coder Social home page Coder Social logo

pndlm / react-table-hoc-draggable-columns Goto Github PK

View Code? Open in Web Editor NEW

This project forked from patricktran/react-table-hoc-draggable-columns

0.0 1.0 0.0 2.3 MB

ReactTable HOC for draggable columns

Home Page: https://patricktran.github.io/react-table-hoc-draggable-columns/

License: MIT License

JavaScript 90.25% HTML 4.06% CSS 5.69%

react-table-hoc-draggable-columns's Introduction

react-table-hoc-draggable-columns

ReactTable HOC for draggable columns

NPM JavaScript Style Guide

Higher Order Component for ReactTable to enable Draggable columns for reordering or swapping positions.

*Note: This version supports V6 of React Table.

Documentation

Install

npm install --save react-table-hoc-draggable-columns

Usage

import ReactTable from 'react-table';
import "react-table/react-table.css";
import withDraggableColumns from 'react-table-hoc-draggable-columns';
import 'react-table-hoc-draggable-columns/dist/styles.css';

const ReactTableDraggableColumns = withDraggableColumns(ReactTable);
...
render () {
  return (
    <ReactTableDraggableColumns
      draggableColumns= {{
        mode: 'reorder',
        draggable: ['firstName', 'age']
      }}
      data={data}
      columns={[
        {
          Header: 'First Name',
          accessor: 'firstName',
        },
        {
          Header: 'Last Name',
          accessor: 'lastName',
        },
        ...
        {
          Header: 'age',
          accessor: 'age',
        }
      ]}
    />
  )
}

draggableColumns Prop

Property Description Default value Type Required
mode mode to either 'reorder' the column or 'swap' column position on drop 'reorder' string yes
draggable array of column accessors to allow drag and drop array of strings
enableColumnWideDrag when {true} entire column is draggable. when {false} only header text is draggable true bool
disableTableScroll disable ReactTable horizontal/vertical scrolling when dragging a column false bool
overflow used with disableTableScroll={true} to reset ReactTable overflow style onDragEnd event auto string
useDragImage clone dragged column element? useful for applying a different css class. true bool
dragImageClassName dragImageClassName only applies when useDragImage={true} rt-dragged-item string
onDragEnterClassName when mode={'swap'} - css class applied on dragged over column rt-drag-enter-item string
onDraggedColumnChange callback method to be notified when column order changes - signature: function(columns) function
onDropSuccess callback method to be notified when on column drop success - signature: function(draggedColumn, targetColumn, oldIndex, newIndex, oldOffset, newOffset) function
reorderIndicatorUpClassName additional className for reorder indicator Up string
reorderIndicatorDownClassName additional className for reorder indicator Down string

License

MIT © patricktran

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.