Giter Club home page Giter Club logo

editablegrid-mysql-example's Introduction

editablegrid-mysql-example

This example shows how to use EditableGrid with a MySQL database

Installation

First, create a database and load the script demo.sql

shell> mysql -u root -ppassword
mysql> create database demo; use demo; source demo.sql

Then copy config.php.sample to config.php and edit the values with yours.

$config = array(
"db_name" => "",
"db_user" => "",
"db_password" => "",
"db_host" => "localhost"
);   

You can load index.php in a browser and you should see the content of the table demo.

Filter

Client side

It's very easy to filter the content of the table. You can use

EditableGrid.prototype.filter = function(filterString, cols)

In this exemple, the filter operates on all columns

datagrid.editableGrid.filter( $(this).val());

but you can filter only on some columns. Below, the filter operates on columns 0, 3 and 5.

datagrid.editableGrid.filter( $(this).val(), [0,3,5]);

CRUD Actions

A column action (type HTML) has been added. With a renderer, the content is redefined to add icons or any components to manage actions on the row

Delete

The delete fonction call delete.php with the tablename and the row id. The script executes the query that deletes the row and returns a status. If it's ok, we remove the row from the javascript model :

if (response == "ok" )
	        self.editableGrid.removeRow(id);

Responsive

This example uses the first technique describes here http://elvery.net/demo/responsive-tables/. This technique is very simple, it hide less important columns on smaller screen sizes.

editablegrid-mysql-example's People

Contributors

jybeaujean avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.