duan0531 2014-11-15 21:48
浏览 113
已采纳

DHTMLX DataProcessor不保存对数据库的更改

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条回答 默认 最新

  • duankui3838 2014-11-29 19:18
    关注

    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条)

报告相同问题?

悬赏问题

  • ¥50 汇编语言除法溢出问题
  • ¥50 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗