• Stars
    star
    154
  • Rank 241,219 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

jQuery editTable is a very small jQuery Plugin (~1Kb gzipped) that fill the gap left by the missing of a default input field for data tables.

jQuery editTable

jQuery editTable is a very small jQuery Plugin (~1Kb gzipped) that fill the gap left by the missing of a default input field for data tables. jQuery editTable can be used both in ajax and/or HTTP POST contest and let you preset the title and number of columns or just let complete freedom to the user. You can even append custom behaviors to single column cells (ex. jQuery UI Datepicker). The only limit is your imagination! :)

To use it you just have to include jQuery and a copy of the plugin in your head or footer:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="jquery.edittable.min.js"></script>
<link rel="stylesheet" href="jquery.edittable.min.css">

Now you can trigger editTable on any textarea or block element (ex. div, article, section ...). In case you trigger it on a textarea, its content will be used as JSON source for the table. If the textarea is inside a form, on submit, its content will be updated with the new JSON data. Otherwise, if you trigger it on a block element the table will be appended to the element itself (ajax).

var mytable = $('#edittable').editTable({
    data: [['']],           // Fill the table with a js array (this is overridden by the textarea content if not empty)
    tableClass: 'inputtable',   // Table class, for styling
    jsonData: false,        // Fill the table with json data (this will override data property)
    headerCols: false,      // Fix columns number and names (array of column names)
    maxRows: 999,           // Max number of rows which can be added
    first_row: true,        // First row should be highlighted?
    row_template: false,    // An array of column types set in field_templates
    field_templates: false, // An array of custom field type objects

    // Validate fields
    validate_field: function (col_id, value, col_type, $element) {
        return true;
    }
});

There are of course many methods which can be used on the created table. Let's see...

mytable.loadData(dataArray);    // Fill the table with js data
mytable.loadJsonData(jsonData); // Fill the table with JSON data
mytable.getData();              // Get a js array of the table data
mytable.getJsonData();          // Get JSON from the table data
mytable.reset();                // Reset the table to the initial set of data
mytable.isValidated()           // Check if the table pass validation set with validate_field

To define a custom field type object:

[
    'checkbox' : {

        html: '<input type="checkbox">',     // Input type html

        // How to get the value from the custom input
        getValue: function (input) {
            return $(input).is(':checked');
        },

        // How to set the value of the custom input
        setValue: function (input, value) {
            if ( value ){
                return $(input).attr('checked', true);
            }
            return $(input).removeAttr('checked');
        }
    }
]

That's it, now give a look to the examples to understand how it works.

Credits and contacts

ReStable has been made by me. You can contact me at [email protected] or twitter for any issue or feauture request.

More Repositories

1

fontIconPicker

🌈 jQuery fontIconPicker v2 is a small (3.22kb gzipped) jQuery plugin which allows you to include a simple icon picker with search and pagination inside your administration forms.
HTML
267
star
2

ReStable

🌈 jQuery plugin that makes tables responsive converting them to HTML lists on small viewports.
JavaScript
189
star
3

Nuwk

Nuwk! makes it easy to create Mac Applications based on node-webkit, simplifying testing and building procedures. It takes care of creating the executable, attaching the app icon and configuring the plist file accordingly.
JavaScript
106
star
4

mailamie

🌈 Mailamie is a simple SMTP catch all server for testing written in PHP.
PHP
77
star
5

ReSmenu

jQuery ReSmenu - Select based responsive menu
JavaScript
64
star
6

wp-heartbeat-notify

Based on WordPress 3.6 heartbeat API, Wp Hearbeat Notify, display a realtime custom message to your visitor each time a new post is published with a link redirecting to it. Still in beta version, this plugin has been full tested only on WordPress 3.6-beta3.
PHP
50
star
7

acf-fonticonpicker

ACF { fontIconPicker is a Fonts Icons Picker field type for the Advanced Custom Fields WordPress plugin.
HTML
47
star
8

cookie-notice-js

Vanilla JS that seamlessly add a notice for the European Cookie Law to any website
JavaScript
46
star
9

Twitter-API-1.1-Client-for-Wordpress

A simple class to query Twitter API v1.1 from WordPress with caching
PHP
38
star
10

rooles

A very simple package to handle Roles and Permissions in Laravel 5.1
PHP
11
star
11

WpDevTool

Development tools for WordPress
PHP
5
star
12

Cocoon

WordPress plugin that provides a Laravel like framework
PHP
2
star
13

lazyResp

jQuery plugin to lazy load responsive images with retina support
JavaScript
2
star
14

PostmanCanFail

Notice via mail() or Rollbar in case of WordPress Postman SMTP Mailer sending errors. Postman logging must be enabled.
PHP
2
star
15

email-extract

Extracts all email addresses from a given file and saves them in a new text file.
JavaScript
2
star