Coder Social home page Coder Social logo

gigatables / reactables Goto Github PK

View Code? Open in Web Editor NEW
143.0 9.0 32.0 14.77 MB

GigaTables is a ReactJS plug-in to help web-developers process table-data in applications and CMS, CRM, ERP or similar systems.

License: MIT License

HTML 0.13% JavaScript 93.50% CSS 6.37%
react javascript grids tables webpack2 reactjs reactjs-components reactjs-es6 table grid

reactables's Introduction

This progect won't be supported anymore, use newer and better version for ReactJS GigaTables/reactables

https://github.com/GigaTables/reactables

GigaTables JQuery plug-in

GigaTables is a plug-in to help web-developers process data in applications and CMS, CRM, ERP or similar systems. Unlike other JQuery-based tables (which earn money from CRUD operations) it is under MIT license - totally free

Supported package managers

  • npm install gigatables
  • bower install gigatables (--allow-root, for sudo)
  • composer require gt/gigatables

Fiew screen-shots

Multiple select with Ctrl and Shift

alt tag

CRUD pop-ups

alt tag

Installation

    <script src="jquery.js"></script>
    <script src="src/js/jquery.gigatables.js"></script>
    <link href="src/css/jquery.gigatables.css" rel="stylesheet" type="text/css"/>

To use GigaTables editor:

    <script src="src/js/gigatables.editor.js"></script>
    <link href="src/css/gigatables.editor.css" rel="stylesheet" type="text/css"/>        

Getting Started

To initialize plug-in and to bind GigaTables with table structure You don't need to do a lot - just call a GigaTables with options and set table structure in HTML. The tag, it's rows and all the stuff like pagination, per page selector will be constructed automatically and only if U need this.

Minimal configuration

        $('#gigatable').GigaTable({
          struct: {// all in
            search: ['top', 'bottom'],
            rowsSelector: ['asc', 'top', 'bottom'],
            pagination: ['bottom']
          },
          ajax: 'gigatables.php',
          columns: [
            {data: "id"},
            {data: "desc"},
            {data: "title"},
            {data: "date"},
            {data: "types"},
            {data: "info"}
          ]
        });   

To turn on/off parts You can simply define this in struct, for instance to turn off pagination and rowsSelector do the following:

          struct: {
            search: ['top', 'bottom'],
            rowsSelector: [], // turn off selectors
            pagination: []  // turn off pagination
          },

Advanced configuration with opts and editor

        $('#gigatable').GigaTable({
          struct:{ // all in
            search : ['top', 'bottom'], 
            rowsSelector: ['asc', 'top', 'bottom'], 
            pagination: ['bottom']
          },
          lang:'ru', // english default
          perPageRows: [25, 50, 100, 200, 500], // default behavior 
          defaultPerPage : 50,          
          ajax:'gigatables.php', // to return JSON structure - see example bellow 
          columns: [
            { // include all defaults
              data: "id", 
              sortable: true, // default
              visible: true, // default
              searchable: true // default
            },
            {data: "desc", sortable: false // turn off sorting},
            {data: "title"},            
            {
              data: "date", 
              searchable: false // turn off searching 
            },                    
            {
              data: "info", 
              visible: false // turn off from viewing this column content
            } 
            
          ],
          columnOpts: [ // optionally U can render any columns as U want or skip this option
            {
              render: function(data, row, type) {
                return '<div><form method="post" class="accForm" action=""><input type="hidden" name="action" value="forms" /><input type="hidden" name="id" value="' + row.id + '" /><div>' + data + '</div></form></div>';
              }, 
              target: 2
            }, 
            {
              render: function(data, row, type) {
                return '<div><form method="post" class="accForm" action=""><input type="hidden" name="action" value="forms" /><input type="hidden" name="id" value="' + row.id + '" /><div>' + data + '</div></form></div>';
              }, 
              target: 3
            }            
          ],
          tableOpts: { // this is only for editor plug-in which helps edit every row with any type 
            buttons: [ // additionally U may want put some trigger function before/after popup creation ex.: to set autocomplete on field etc
              {extended: "editor_create", editor: editor, triggerAfter:(function() {
                console.log('after create');
              }), triggerBefore:(function() {
                console.log('before create');
              })},
              {extended: "editor_edit", editor: editor},
              {extended: "editor_remove", editor: editor, triggerAfter:(function() {
                console.log('after del');
              })}             
            ],            
            buttonsPosition: ['top', 'bottom'], // buttons for popup editing
            theme: 'std'
          }          
        });  

The table is defined like in example below:

    <table id="gigatable">
      <thead>
        <tr>
          <th>ID</th>
          <th>Name</th>
          <th>Description</th>
          <th>Date</th>
          <th>Types</th>
          <th>Info</th>
        </tr>
      </thead>
      <tfoot>
        <tr>
          <th>ID</th>
          <th>Name</th>
          <th>Description</th>
          <th>Date</th>
          <th>Types</th>
          <th>Info</th>
        </tr>
    </tfoot>
  </table>

JSON structure to be return from provided url in "ajax" GigaTables option:

{
    "rows": [
        {
            "GT_RowId": 2, // optional 
            "id": 2, // if there is no GT_RowId - try to fetch "id"
            "title": "Test 2st row",
            "desc": "<input type=\"text\" name=\"ttl\" value=\"Test 2st row Test 2st row Test 2st row
 Test 2st row Test 2st row\" \/> ",
            "date": "20:40:37 17:06:2015",
            "info": "some info some info some info some info"
        },
        {
            "GT_RowId": 1,
            "id": 1,
            "title": "Test 1st row",
            "desc": "<input type=\"text\" name=\"ttl\" value=\"Test 1st row Test 1st row Test 1st row
 Test 1st row Test 1st row\" \/> ",
            "date": "20:40:38 17:06:2015",
            "info": "some info some info some info some info"
        }, ...

An example of using GigaTables with Editor tool

First of all You should define a class Editor like this:

        var editor = new $.fn.GigaTable.Editor({
          ajax: 'editor.php',
          ajaxFiles: 'uploadFiles.php',
          struct: {
            buttons: ['top', 'bottom'] // buttons
          },
          fields: [
            {
              label: "ID",
              name: "id",
              type: 'hidden'
            },                    
            {
              label: "Article title:",
              name: "title",
              type: 'text' // default, other: password, file, select, multiselect etc
            },
            {
              label: "Description:",
              name: "desc",
              type: 'textarea'
            },
            {
              label: "Date Time:",
              name: "date",
              type: 'date'
            },
            { // an example of using select - automatically selected if matches with data in table column
              label: "Types:",
              name: "types", 
              values: [ // if select,checkbox,radio etc types - need this kinda structure of value
                  {'key1':'val1'}, 
                  {'key2':'val2'}
              ],            
              type: 'select', // select,checkbox,radio
              attrs: [
                {'multiple':true}
              ]
            },
            {
              label: "Image:",
              name: "image",
              type: 'file'
            }
          ]

        });

and then pass variable (in this case - editor) to GigaTables main options in tableOpts section like this:

          tableOpts: {
            buttons: [
              {extended: "editor_create", editor: editor},
              {extended: "editor_edit", editor: editor},
              {extended: "editor_remove", editor: editor}
            ],
            buttonsPosition: ['top', 'bottom'],
            theme: 'std'
          }

That's it then You will be able to CRUD any record You want :-)

FAQ

Can I use file types in GT editor to upload files through AJAX on server?

Sure, it can be done by this additional option in editor:

ajaxFiles: 'uploadFiles.php',

wich is point on script on the server where it should upload the file(s).

And to add the actual field which will send the file to the server script:

            {
              label: "Image:",
              name: "image",
              type: 'file'
            }

Ensure that the field is in fields: [ option.

What types of fields can be used in editor?

Any, really - You can use any HTML5 types, they are already embedded, but responsibility of supported ones (in different Browsers) is on Your side.

Can I choose more then one row?

Yes, U can even choose not only the bunch of rows, but several bunches and some between them, by manipulating with: Ctrl+Left click (one row anywhere) and Shift+Left click (several rows).

Can I sort columns content?

Defenitelly, also it is simple enough to sort them jointly.

What does search field mean?

The main search field above (which is the default state, U can make it visible in the bottom) is useful for searching through all columns.

Is it possible to search for a particular column in GT?

Yes it is, U can specify any column U wanted to search by setting these options in columns parts eg.:

          columns: [
            {// include all defaults
              data: "id",
              discreteSearch: true, 
              discreteSearchValue: function(title) {
                return 'Search on the field - ' + title;
              }              
            }

additionally U may want to set a custom placeholder - it is possible via discreteSearchValue option.

Is there languages support?

Sure, You can pick one of 7 languages: English, German, Russian, French, Spanish, Chinese, Hindi - en, gr, ru, fr, es, ch, hi respectively.

Does GT have any event-triggered functions, ex.: to run something before/after pop-up?

GigaTables plug-in has 2 types of triggers triggerBefore and triggerAfter which can be applied to any action button - Create, Edit or Delete.

reactables's People

Contributors

andreienache avatar angeloanolin avatar arthurkushman 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  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  avatar  avatar  avatar

reactables's Issues

Implement arrow row selection movements by W3C wai-aria-practices-1.1

Ctrl+Down Arrow: Moves focus one cell down. If focus is on the bottom cell in the column, focus does not move.
Ctrl+Up Arrow: Moves focus one cell Up. If focus is on the top cell in the column, focus does not move.
Ctrl+End: Moves focus down an author-determined number of rows, typically scrolling so the bottom row in the currently visible set of rows becomes one of the first visible rows. If focus is in the last row of the grid, focus does not move.
Ctrl+Home: Moves focus up an author-determined number of rows, typically scrolling so the top row in the currently visible set of rows becomes one of the last visible rows. If focus is in the first row of the grid, focus does not move.

Ctrl is crucial to move selection of rows bc user may want to just scroll by those keys.

Unable to render Reactables

Hello! I am implementing a table without editor settings for a React app I'm creating, as I don't need the editor portion. I get error Uncaught TypeError: Cannot read property 'fields' of undefined when the component attempts to load in browser. In Firefox, I see TypeError: t is undefined, but I don't know if that's a separate issue.

React Version: 15.5.4

Not an issue - Just help needed

Hi,

I am trying to test your tables in my react project as your component is the closest to my requirement.

I cant for the life of me get it to work though, here is my code below, maybe you can tell me if im doing something wrong. Im a newbie with react, so this could be adding to the problem but Ive tried for many hours, so please bare with me.

I have populated the test.php file with the same code from your php file and when i run it in my terminal it renders the results.

When I run this my main container div in the app is rendering nothing, not even the card.

import React from 'react';
import { Reactables, Header, editor } from 'gigatables-react';
import { Card, CardTitle} from 'reactstrap';

var settings = {
struct: {
search: ['top', 'bottom'],
rowsSelector: ['desc', 'top', 'bottom'],
pagination: ['bottom']
},
lang: 'en', // english default
perPageRows: [25, 50, 100, 200],
defaultPerPage: 100,
ajax: 'test.php',
// ajaxAutoloadData: true, // default false
// ajaxAutoloadPeriod: 8, // sec
requestType: 'GET',
columns: [
{// include all defaults
data: "id",
sortable: true, // true by defualt
visible: true, // true by defualt
searchable: true, // true by defualt
discreteSearch: true, // false by default
discreteSearchValue: function (title) {
return 'Search by field - ' + title;
}
},
{
data: "title",
cISearch: true // default false
},
{
data: "desc",
sortable: false,
discreteSearch: true,
discreteCISearch: true // default false
},
{
data: "date",
searchable: false
},
{
data: "info"
},
{data:"field1"},
{data:"field2"},
{data:"field3", visible: false}
],
columnOpts: [
{
render: (data, row, type) => (





{data}


),
target: 'title' // provide data column index to match opts
},
{
render: (data, row, type) => (

{data}

{(row.id % 2 === 0) ? '**' : '*'}


),
target: 'date'
}
],
tableOpts: {
buttons: [
{extended: "editor_create", editor: editor, triggerAfter: (function () {
console.log('after create');
}), triggerBefore: (function () {
console.log('before create');
})},
{extended: "editor_edit", editor: editor, triggerBefore: (function () {
console.log('before edit');
})},
{extended: "editor_remove", editor: editor, triggerAfter: (function () {
console.log('after del');
})}
],
buttonsPosition: ['top', 'bottom'],
theme: 'std'
}
};

export default class UserManPage extends React.Component {

render() {
return (

  <div>
    <Card block>
      <CardTitle>My Table</CardTitle>
        <Reactables editor={editor} settings={settings}>
          <Header data="id">ID</Header>
          <Header data="title">Name</Header>
          <Header data="desc">Description</Header>
          <Header data="date">Date</Header>
          <Header data="info">Info</Header>
          <Header data="field2">Field123 but data from field2</Header>
          <Header data="field1">Field1</Header>
          <Header data="field3">Field3 invisible</Header>
          <Header>Field3 invisible</Header>
        </Reactables>
    </Card>
  </div>
);

}
}

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.