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

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧