gpt4 book ai didi

javascript - DHTMLX 网格提取附加数据

转载 作者:行者123 更新时间:2023-11-29 07:21:48 25 4
gpt4 key购买 nike

我正在尝试构建一个应用程序,供用户提交他们的工作时间,但在将其他数据拉入网格时遇到问题。

例如:如果用户要在员工代码列中输入员工代码 0000,则员工姓名字段需要更新为“John Doe”。所有这些数据都存储在后端的数据库中,我有能够在刷新时访问它,例如。如果在创建新行并且存在数据后重新加载页面,它将提取正确的数据,但我不希望他们必须刷新页面才能执行此操作。单元格更新后如何提取额外的数据。

网格是使用 JavaScript 在页面上创建的,如下所示:

timesheetGrid.setColumnIds("Column Names, Column Names");
timesheetGrid.setImagePath("codebase/imgs/"); //set the image path for the grids icons
timesheetGrid.setInitWidths("70,100,100,100,70,100,150,100,70,70,100,70,70,*,*"); //sets the initial widths of columns
timesheetGrid.setColAlign("center,center,center,center,center,center,center,center,center,center,center,center,center,left,left"); //sets the alignment of columns
timesheetGrid.setColTypes("edn,ro,dhxCalendar,ro,edn,ro,ed,ro,ro,ro,ed,edn,ch,txt,ro"); //sets the types of columns
timesheetGrid.setColSorting("str,str,date,date,str,str,str,str,str,str,str,str,str,str,str"); //sets the sorting types of columns
timesheetGrid.setDateFormat("%Y-%m-%d"); //Set the Date Format to be used in the Grid
timesheetGrid.attachHeader("#text_filter,#text_filter,#text_filter,,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,,,");
timesheetGrid.setColumnHidden(3,true);
timesheetGrid.enableEditEvents(true,false,true);
timesheetGrid.init();
//timesheetGrid.makeFilter("WeekEnding",0); //TODO: Add Filter For Week Ending
//this.lockRow(id, true); //Make Specific Row Read Only TODO: Non Active Week Rows Read Only
timesheetGrid.load("data/timesheets.php");
var dpg = new dataProcessor("data/timesheets.php");
dpg.enableDataNames(true); // will use names instead of indexes
dpg.init(timesheetGrid);

PHP 用于从正确的途径提取数据

require("../codebase/connector/grid_connector.php");//adds the connector engine
$conn = new GridConnector($res,"MySQL"); //initializes the connector object
if ($conn->is_select_mode()) {//code for loading data
SQL Code is HERE
}else { //code for other operations - i.e. update/insert/delete
OTHER SQL CODE IS HERE
}

由于数据很敏感,我无法显示任何数据,对于给您带来的不便,我们深表歉意。任何帮助将不胜感激。

最佳答案

如果您提供的数据是 XML,您可以将一个事件附加到您的网格并调用此 grid.updateFromXML("data/timesheets.php");这将解析并绘制整个网格信息

如果您只想更新您更新的行,您可以通过 GET 发送该行的 id,它只会解析并绘制您要发送的行grid.updateFromXML("data/timesheets.php?for="+ row_id));

完整代码如下:

dpg.defineAction ("update", myUpdate);
function myUpdate(tag){
timesheetGrid.updateFromXML("data/timesheets.php?for="+tag.getAttribute("sid"));
return true;
}

如果您检索的数据不是 XML 格式,恐怕您需要通过同一事件手动更新行中的值。

关于javascript - DHTMLX 网格提取附加数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35878027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com