Code Monkey home page Code Monkey logo

editablegrid-mysql-example's People

Contributors

greg31 avatar jybeaujean 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

Watchers

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

editablegrid-mysql-example's Issues

Displaying Images

I've stored image links on MySQL database. Is there a way they can be displayed in the grid?

message div does not display in example

Wonderful software. Thank you.
I notice that the message line does not display in this mysql-example. It does in the 'full example' in the full master. I found that I could not work out how to activate or have the message to display. It could be useful.

Filter

Kindly help me in implementing Filter and Charts !

Input Mask

I've managed to add an Input mask in the add window. But when it comes to update a record row it doesn't work (I'm using jquery.inputmask.js plugin)

AddColumn and data from another table

Hi
I try to get data from another table into one column:

function fetch_d($mysqli,$query){
if (!($res = $mysqli->query($query)))return FALSE;
$row = $res->fetch_array();
return $row['email'];
}

$grid->addColumn('email', 'email', 'string' , fetch_d($mysqli,'SELECT email FROM contactinfo WHERE id=1'),true);

But it's not working. Could you help me?

Datetime fields not updating

I have added my own table and most values update with no problem. But unfortunately the datetime fields will not update. They display fine, but on updating they turn red and return to their initial state.

How can I debug this error? echoing the query doesn't seem to work, so I have no clue what is going wrong.
Can it be caused by these lines in update.php:
$date_info = date_parse_from_format('d/m/Y', $value); $value = "{$date_info['year']}-{$date_info['month']}-{$date_info['day']}";

They seem to fine, they pick up the date from the vield and then write in y-m-d to database.
Unfortunately can't see an error message or a message in the log files.

Hope to hear from you :)

Number displaying as double in editablegrid-mysql

There is a little issue with the grid that it displays number as double, For example when the id is 1000 it displays the value as 1.000 though the datatype is integer. I have checked the code but unable to find the correct one.

Feature question

Hi!

I use a database that has a date column, and I want to highlight the row that contains a date that is previous to the current date.
Is it possible to permanently highlight a row with value match (like: if it's less than X, then mark yellow)? (I only found the error and succes highlights)

Thanks

Update fields

Hi, When I try update any field i view red light, and field doesn't update in BBDD.

EDIT: I have find the problem (i was using a custom database). I remade update.php and works fine.

Cannot load table contents from database

I've nginx, php-fpm, and mariadb set up for trying EditableGrid out.

I have imported demo.sql and filled config.php with the database credentials.

I get the following page when I open localhost/index.html in the browser:

jun-29-17_13-06-52_652x157

Please help me with that.

Table name as variable

My table name changes and i need it as a variable and currently have it in a php session variable. However, i cant figure out how to get my php session variable to the demo.js file to define the table name. Any ideas?

no hidden column

hidden is set to true, the column is getting displayed, no hidden column
how modify editablegid.js or how fix this error

renderXML in editablegrid-mysql-example does not create xml for "data".

When I tried to run the example, the xml produced stopped after "MetaData". The example produced the header portion but there was no data. The database was set up correctly. I noticed that the EditableGrid.php packaged with the example was different than the one in the base release so I replaced the EditableGrid.php in the example with the one in the latest release and it now works.

This is a great package and I really appreciate all the work that went into it. Thanks...

date from datepicker - no update

Hello,
i try to use datepicker but when i modify the date, it doesn't run.
Date stays the same than before and i have an error red colored..

how can i correct this ?

thank you

how to upload file ?

hello,
in the add form, i would like to add the way to upload a file (jpeg...)
How can i do this ?

thanks

Question(s)

  1. Is which css file is the column header position changed. I'm trying to get the column headers centered but nothing I've tried is working.

  2. Is it possible to only have the Action column show up when a user is logged in? I wasn't sure how it would affect the xml etc. Same goes for editing. I'm wanting the data to be view-able to everything but only admin's can edit/delete etc.

  3. Is it possible to hide the column if a user isn't logged in. I don't want all users to be able to delete rows, just ones logged in or logged in as an admin user etc.I'm not sure how to hide that since the column is rendered in js. I kind of faked it so that a non-logged in user can't delete but they still still the icon and column. I have this in the loaddata.php

if (!isset($_SESSION['user_id'])) {
$grid->addColumn('action', '', '', NULL, false, '');
} else {
$grid->addColumn('action', 'Del Action', 'html', NULL, false, 'id');
}

  1. Also I see from other posts that it sounds like you may still be working on this project. If that's the case are you planing on adding "rows per page" functionality?

Awesome work by the way.

Combobox into column question

I would like to understand how to parameterize the query goes to populate the combobox with the name of my column Tg_Filter.

For I would that the query was

select Tg_Filter, VALUE from T_TG WHERE Tg_Filter = ????

Where Is That ???? is equivalent to the field Tg_Filter table T_Main

How can I do?

Table structure

T_MAIN

Id integer autoincrement
FullName string
Tg_Filter integer

T_TG
Id integer autoincrement
Tg_Filter integer
Value string

T_Main

1;Francesco;1
2;Andrea;2
3;Sara;2
4;Carmen;2

T_TG
1;1;stringa1
2;1;stringa2
3;2;stringa3
4;2;stringa4

My Code

// create a new EditableGrid object
$grid = new EditableGrid();
$db_tablename = (isset($_GET['db_tablename'])) ? $_GET['db_tablename'] : 'T_UTENTI';

$connection = new PDO($str_conn,$config['db_user'],$config['db_password']);
/* 
*  Add columns. The first argument of addColumn is the name of the field in the databse. 
*  The second argument is the label that will be displayed in the header
*/

$grid->addColumn('ID', 'MyID', 'integer', NULL, false);     
$grid->addColumn('FULLNAME', 'MyFullName', 'string');  
$grid->addColumn('Tg_Filter', 'MyFilter', 'string',fetch_pairs($connection,'select Tg_Filter, VALUE from T_TG WHERE Tg_Filter=???? '),true);  
$grid->addColumn('action', 'ACTION', 'html', NULL, false, 'ID');


$app=$connection->prepare('SELECT * FROM T_Main');
$app->execute();

$result = $app->fetchAll();

$connection = null;

// send data to the browser
$grid->renderXML($result);

How to modify "integer" column format?

Currently trying to figure out how to modify an integer column so that it does not display decimal points.
For example one of my columns consists of 7 digit numbers and currently is being displayed as 5.014.546. How can I change this so that it is displayed without the decimal points?

Not returning json or xml

I am trying to test the editablegrid but nothing is returning from EditableGrid.php. After the foreach in the getPOJO function something is going wrong and loses all the variables. So I get an empty page.

I am using the demo table from the example. The php version is 5.6

Updating Error

Hi there!
I cannot update my table when i change information. The row highlighted red and not update the information

update.php

<?php

/*
 * 
 * This file is part of EditableGrid.
 * http://editablegrid.net
 *
 * Copyright (c) 2011 Webismymind SPRL
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://editablegrid.net/license
 */

require_once('config.php');         

// Database connection                                   
$mysqli = mysqli_init();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
$mysqli->real_connect($config['db_host'],$config['db_user'],$config['db_password'],$config['db_name']); 

// Get all parameters provided by the javascript
$colname = $mysqli->real_escape_string(strip_tags($_POST['colname']));
$id = $mysqli->real_escape_string(strip_tags($_POST['id']));
$coltype = $mysqli->real_escape_string(strip_tags($_POST['coltype']));
$value = $mysqli->real_escape_string(strip_tags($_POST['newvalue']));
$tablename = $mysqli->real_escape_string(strip_tags($_POST['tablename']));



// This very generic. So this script can be used to update several tables.
$return=false;
if ( $stmt = $mysqli->prepare("UPDATE $tablename SET $colname = $value WHERE idoferta = $id")) {
    $return = $stmt->execute();
    $stmt->close();

}             
$mysqli->close();        

echo $return ? "ok" : "error";

If you need anything else, let me know.
Thank You for the help ;)

Dropdown box putting ID# in Mysql need to be Value

Added Editablegrid to an exsisting php project. When logged in as admin the member can edit the grid and the dropdown fields show the value . but when log out and an normal user views the page (non editable). the php-Mysql display show the ID # where the value should be . how to get grid to save the value not the ID in mysql from a dropdown menu?

This is the Grid showing the value
grid

the loaddata code

<?php     
session_start();

/*
 * examples/mysql/loaddata.php
 * 
 * This file is part of EditableGrid.
 * http://editablegrid.net
 *
 * Copyright (c) 2011 Webismymind SPRL
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://editablegrid.net/license
 */


/**
 * This script loads data from the database and returns it to the js

  *
 */


require_once('config.php');      
require_once('EditableGrid.php');  



/**
 * fetch_pairs is a simple method that transforms a mysqli_result object in an array.
 * It will be used to generate possible values for some columns.
*/
function fetch_pairs($mysqli,$query){
    if (!($res = $mysqli->query($query)))return false;
    $rows = array();
    while ($row = $res->fetch_assoc()) {
        $first = true;
        $key = $value = null;
        foreach ($row as $val) {
            if ($first) { $key = $val; $first = false; }
            else { $value = $val; break; } 
        }
        $rows[$key] = $value;
    }
    return $rows;
} 


// Database connection
$mysqli = mysqli_init();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
$mysqli->real_connect($config['db_host'],$config['db_user'],$config['db_password'],$config['db_name']); 


// create a new EditableGrid object
$grid = new EditableGrid();

/* 
*  Add columns. The first argument of addColumn is the name of the field in the databse. 
*  The second argument is the label that will be displayed in the header
*/
$grid->addColumn('asset_hardware_id', 'ID', 'integer', NULL, false); 
$grid->addColumn('location', 'Location', 'string', fetch_pairs($mysqli,'SELECT id, location FROM location'),true);  
$grid->addColumn('cube', 'Room', 'string');  
$grid->addColumn('asset_type', 'Type', 'string', fetch_pairs($mysqli,'SELECT id, assets_hardware_type FROM assets_hardware_type'),true); 
$grid->addColumn('vendor', 'Vendor', 'string', fetch_pairs($mysqli,'SELECT vendor_id, vendor FROM vendors'),true ); 
 $grid->addColumn('model', 'Model', 'string');
 $grid->addColumn('asset_tag', 'Asset Tag', 'string');
 $grid->addColumn('serialnumber', 'Serial Number', 'string');
 $grid->addColumn('delltag', 'Dell Tag', 'string');
 $grid->addColumn('user', 'Name', 'string');
 $grid->addColumn('physically_inventoried', 'Inv?', 'boolean');


$mydb_tablename = (isset($_GET['db_tablename'])) ? stripslashes($_GET['db_tablename']) : 'assets_hardware';

 $result = $mysqli->query("SELECT * FROM ".$mydb_tablename. " WHERE location =  '". $_SESSION['loc'] ."'  and cube = '". $_SESSION['room'] ."'");
$mysqli->close();

// send data to the browser
$grid->renderJSON($result);

this is the PHP website output after using the editablegrid dropdown.
mysql

Non editable

Is there any way to make the table non-editable for some or all columns?

Action Column Empty

Hello, I have the SQL example working. I see the full table and it interacts correctly with the SQL database. However, the Action cell is blank for each record/row. I'm expecting to see a way to delete the record from the database. Is there anything missing from the setup that would trigger something appearing in that cell that would call the delete.php file?

Regarding CellEditor

Hi,
Thanks for the awesome example. I have a few questions?

  1. I have a long text in one of the columns. When i click to edit the text, it appears as one single line. Is it possible to wrap text while editing also?
  2. How can insert new line character in the long text? (i.e. I want the text to appear as bullets or numbered list)
  3. How can I enable charts? I really have no idea :(

setCellRenderer: Invalid Column: action

12.01.2014 - Hello, Please can you help me.
An error occurs in current demo files. "setCellRenderer: Invalid Column: action"
What can i do? (I need the delete function for the gridrow)

Datepicker - monday first day of the week

Hey!
I'm using your editablegrid and have a question/problem:
I want to begin my datepicker with monday instead of sunday. How do I solve that issue? As far as I know do you initialize the datepicker in editablegrid-2.1.0-b25.js but that is not really readable.

Thanks!

Grid not refreshing

I have the PHP demo running... when I delete a record it does it on the DB but does not refresh the grid view and the item still on the grid... I am using the php example files.

the Datagrid don't display

Hi,

I want to display the data of a table with the next columns

  • id
  • name
  • countryId
    And the column 'countryId' is an integer but in the example country is an string
    i don't know what i hav to write
  • $grid->addColumn('countryId', 'Country', 'integer', fetch_pairs($mysqli,'SELECT id, name FROM Country'),true );
  • $grid->addColumn('countryId', 'Country', 'string', fetch_pairs($mysqli,'SELECT id, name FROM Country'),true );
    When I test one of the two codes, the datagrid don't display.

What have I to do ?

Table won't update

When I try to update a cell, it just flashes red then returns to the original value. It doesn't give an error. Some tip?

How filter column base on data from mysql?

hi,
i just try this repo to build my research app.
my sql query something like it:
SELECT * FROM table_name WHERE id='4';

how implement use this script?
any clue.
thanks.

Delete action not working

I have made my own database and table with everything working except for the delete function. When I click the trash icon my alert says:
Are you sure you want to delete the row id null

My table has a column called id and it is unique and auto increment. Since it's reading null I assume something isn't working properly? How to I track down the problem?

This is my delete.php but I am quite sure I did not change this.

`<?php

require_once('config.php');

// Database connection
$mysqli = mysqli_init();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
$mysqli->real_connect($config['db_host'],$config['db_user'],$config['db_password'],$config['db_name']);

// Get all parameter provided by the javascript
$id = $mysqli->real_escape_string(strip_tags($_POST['id']));
$tablename = $mysqli->real_escape_string(strip_tags($_POST['tablename']));

// This very generic. So this script can be used to update several tables.
$return=false;
if ( $stmt = $mysqli->prepare("DELETE FROM ".$tablename." WHERE id = ?")) {
$stmt->bind_param("i", $id);
$return = $stmt->execute();
$stmt->close();
}
$mysqli->close();

echo $return ? "ok" : "error";
`

Question about function calls inside of php file

Hello Jybeaujean, thanks for the work effort is this grid. As i'm trying to implement it I was wondering if its possible to have the update/delete/add commands done through a single php file with functions.

Instead of this for delete row.
$.ajax({
url: 'delete.php',
type: 'POST',
dataType: "html",
data: {
tablename : self.editableGrid.name,
id: id

You could do something like
url: 'functions.php/delete_row'
type: 'POST'

functions.php would have
function delete_row(){......}

The reason I ask is I'm wanting to use the grid for many diff table view's. I'd like to avoid having a dozen different update/delete/add files for each table. I think I'd be fine with just the one delete file but the add/update would differ and each table has diff columns to change. Please let me know if this is possible. I've tried to figure this out on google searches but the function doesn't seem to be getting ran.

Thanks for you time.

FYI...
I've tried some things like.
url: 'inc/functions.php/p2_delete?id='+id+'&tablename='+self.editableGrid.name,

I've put junk in the function like so and nothing is returned..

function p2_delete(){
if(isset($_POST['id']) && !empty($_POST['tablename'])) {
echo "here";
print "here";
var_dump($_POST['tablename']);
php_info();
}
sql code here
}

Displayed Rows Number

Is there a function to show (on header or footer) the number of rows displayed with or without filter(s).
Something like the image below...

screenshot

grid not displaying data

Hi, great tool, thank you.

Please help.
I'm trying to just display one column of data (the first), not all the columns.
When I comment out all addColumn lines except the first column (using your demo), then no data is displayed in the grid.

It appears only if I include the columns 'country' or 'continent' does the grid show results.
If I exclude both those columns, the grid returns no rows, even though the other columns are there.

Thanks

Please create and add charts to mysql example?

Thank you for this mysql example -- it's very informative. However, I've been trying to add charts to this mysql example but having problems. Do you mind adding charts to this example?

Thanks.

Update row by rowid error

I an unable to update row by primary key instead of row index. Reason being, once deleted the rows after the deleted row are out of alignment and updates are made to misaligned cells based on rowid. New to this so if there is any guidance thanks in advance.

HighCharts library not loaded!

The latest untouched download version shows the message "HighCharts library not loaded" and the "rows per page" feature is not working too

loaddata.php patch

I had an issue with loaddata.php

patch loaddata.php < patch.txt

save between SNIP (but do not include SNIP as patch.txt, Or find the - lines and replace them with + lines.
===> SNIP <===
--- loaddata.php.original.broken 2017-08-02 00:56:32.000000000 +0930
+++ loaddata.php.fixed 2017-08-08 15:47:37.000000000 +0930
@@ -75,10 +75,10 @@

$query = 'SELECT *, date_format(lastvisit, "%d/%m/%Y") as lastvisit FROM '.$mydb_tablename ;
$queryCount = 'SELECT count(id) as nb FROM '.$mydb_tablename;

-$totalUnfiltered =$mysqli->query($queryCount)->fetch_row()[0];
-$total = $totalUnfiltered;

+//m3f $totalUnfiltered =$mysqli->query($queryCount)->fetch_row()[0];
+//m3f $total = $totalUnfiltered;
+$totalUnfiltered =$mysqli->query($queryCount)->fetch_row();
+$total = $totalUnfiltered[0];

/* SERVER SIDE /
/
If you have set serverSide : true in your Javascript code, $_GET contains 3 additionnal parameters : page, filter, sort
@@ -98,7 +98,9 @@
$filter = $_GET['filter'];
$query .= ' WHERE name like "%'.$filter.'%" OR firstname like "%'.$filter.'%"';
$queryCount .= ' WHERE name like "%'.$filter.'%" OR firstname like "%'.$filter.'%"';

  • $total =$mysqli->query($queryCount)->fetch_row()[0];
    +//m3f $total =$mysqli->query($queryCount)->fetch_row()[0];
  • $totalUnfiltered =$mysqli->query($queryCount)->fetch_row();
  • $total = $totalUnfiltered[0];
    }

if ( isset($_GET['sort']) && $_GET['sort'] != "" )
===> SNIP <===

Question(s)

Is which css file is the column header position changed. I'm trying to get the column headers centered but nothing I've tried is working.

Is it possible to only have the Action column show up when a user is logged in? I wasn't sure how it would affect the xml etc. Same goes for editing. I'm wanting the data to be view-able to everything but only admin's can edit/delete etc.

Also I see from other posts that it sounds like you may still be working on this project. If that's the case are you planing on adding "rows per page" functionality?

Awesome work by the way.

EditableGrid how to fetch rows from MySql in php

I am trying to do an editable grid table in order to modify directly.
There is a field which I need to list all of it content so that I can select one.
Look at my code :
function fetch_pairs($mysqli,$query){ if (!($res = $mysqli->query($query)))return FALSE; $rows = array(); while ($row = $res->fetch_assoc()) { $first = true; $key = $value = null; foreach ($row as $val) { if ($first) { $key = $val; $first = false; } else { $value = $val; break; } } $rows[$key] = $value; } return $rows; } $grid->addColumn('product-name', 'Product', 'string' , fetch_pairs($mysqli,'SELECT name FROM table_product'),true);
In my database I have two tables:
-table_add{id,product-name}
-table_product{id,name}

But the list is not appearing.
I am getting this error:
Could not load JSON from url 'loaddata.php?db_tablename=table_add'

Any idea why ?

Problem loading XML in demo

Thanks for the demo. It is exactly what I need but I am having a problem and I need a little direction.
I downloaded the zip file, extrated it then up loaded it to my web server. config.php is correct as when I load "loaddata.php" stand alone, I see the xml. When I load index.html, however, I see the header, buttons, everything BUT the table that should have been rendered. I put an alert in the DatabaseGrid constructor just before the this.fetchGrid which triggers. In "fetchGrid, I have alert's before and after "loadXML" which trigger but no data displays.

Any ideas where to look?

edit dates

Hello! Use your software for my purposes, very helpful. How do I set up the ability to edit dates? I use your configuration and settings (just use other names of the columns).

Tried Putting my Own Table

Hi i've tried putting my own table and it seems that it doesnt work :'(
please help me

this is my loaddata.php

query($query)))return FALSE; $rows = array(); while ($row = $res->fetch_assoc()) { $first = true; $key = $value = null; foreach ($row as $val) { if ($first) { $key = $val; $first = false; } else { $value = $val; break; } } $rows[$key] = $value; } return $rows; } // Database connection $mysqli = mysqli_init(); $mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5); $mysqli->real_connect($config['db_host'],$config['db_user'],$config['db_password'],$config['db_name']); // create a new EditableGrid object $grid = new EditableGrid(); /\* - Add columns. The first argument of addColumn is the name of the field in the databse. - The second argument is the label that will be displayed in the header */ $grid->addColumn('ID', 'ID', 'integer', NULL, false); $grid->addColumn('title', 'Name', 'string'); $grid->addColumn('date', 'Firstname', 'date'); $grid->addColumn('info', 'Age', 'string'); $grid->addColumn('action', 'Action', 'html', NULL, false, 'ID'); $mydb_tablename = (isset($_GET['db_tablename'])) ? stripslashes($_GET['db_tablename']) : 'announcement'; $result = $mysqli->query('SELECT *, date_format(lastvisit, "%d/%m/%Y") as lastvisit FROM '.$mydb_tablename ); $mysqli->close(); // send data to the browser $grid->renderJSON($result);

Cannot update date fields

Whenever I click a date field, the text field has a red background, then I select a date and it flashes red, indicating it cannot change the value in my mysql database. Any other data type can be changed just fine (e.g. string). Any ideas?

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.