DHTMLX DataProcessor not saving changes to database

1.1k views Asked by At

I have a rather simple DHTMLX page that I'm working on. I managed to load data from a database and display it in a DHTMLXGrid. However, when I change data in the grid, the data is not saved to the database and is therefore lost when the page is reloaded.

The database in question is three tables: users, shows and watching. watching is the only one that needs updating (right now at least) and I just can't seem to get it to work.

This is my "connector.php" file

<?php
require("codebase/connector/grid_connector.php");
require("codebase/connector/db_mysqli.php");
$servername     = "nope";
$username       = "nope";
$password       = "nope";
$databaseName   = "nope";
$conn = new mysqli($servername, $username, $password,$databaseName);
$query = "SELECT watching.user_ID, watching.show_ID,shows.name, watching.episodeswatched, shows.episodes, (shows.episodes - watching.episodeswatched) AS episodesremaining, watching.dropped, watching.waiting FROM watching INNER JOIN shows ON watching.show_ID = shows.ID INNER JOIN users ON watching.user_ID=users.ID";
$gridConnector = new GridConnector($conn, "MySQLi");
if($gridConnector->is_select_mode())
    $gridConnector->render_complex_sql($query,"ID","name,episodeswatched,episodes,episodesremaining,dropped,waiting","user_ID,show_ID");
else 
{
    $gridConnector->render_table("watching","ID", "episodeswatched,dropped,waiting","user_ID,show_ID");
}
?>

And the relevant parts of the Javascript to make the processor and DHTMLXGrid

showsGrid.init();
showsGrid.load("connector.php");
var myDP = new dataProcessor("connector.php")
myDP.enableDataNames(true);
myDP.init(showsGrid);

I tried using the same line for fetching data and updating (render_complex_sqlquery) but that does nothing but paint the row in question red. At least with this method the row stays black.

Am I missing something? Am I doing something completely wrong? I've been completely stuck here for way too long and I'm admitting defeat. I've looked at every sample and tutorial I could find, scoured the documentation and found no help for this.

Forgot the GitHub link: https://github.com/lightspeed1001/dhtmlxdemo

2

There are 2 answers

0
Mikael On BEST ANSWER

I updated the connector.js and some other things, also messed with the names for the cells a bit and now it works.

You can view the diff on the github page for details.

Also, I needed to have datanames enabled, because of how many values I have and they aren't always in the same order when recieving and sending data.

1
Aquatic On

You need to remove the "myDP.enableDataNames(true);" line

This command can be used with custom backend, but while you are using connector on server side you must use the default data sending mode.