Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json tablator-Cell.setValue为自定义格式化程序创建递归循环,表不保存数据_Json_Recursion_Tabulator - Fatal编程技术网

Json tablator-Cell.setValue为自定义格式化程序创建递归循环,表不保存数据

Json tablator-Cell.setValue为自定义格式化程序创建递归循环,表不保存数据,json,recursion,tabulator,Json,Recursion,Tabulator,我会尽量简短,因为我的情况是独特的,我是一个相当新的程序员 TL:DR-无法获取要更新的行,编辑时表格不记得初始值,cell.setValue()创建递归循环,cell.getRow().update()似乎什么都不做,在编辑工作时行不调整大小(仍然不保留以前的值)),不确定是mutator还是cellEdit()回调是潜在的解决方案 我将JSON数据从AJAX调用填充到Java后端的表中。其中一列可以是一个项目、多个项目的列表,也可以完全没有。我正在使用一个自定义格式设置程序,用项目列表填充该

我会尽量简短,因为我的情况是独特的,我是一个相当新的程序员

TL:DR-无法获取要更新的行,编辑时表格不记得初始值,cell.setValue()创建递归循环,cell.getRow().update()似乎什么都不做,在编辑工作时行不调整大小(仍然不保留以前的值)),不确定是mutator还是cellEdit()回调是潜在的解决方案

我将JSON数据从AJAX调用填充到Java后端的表中。其中一列可以是一个项目、多个项目的列表,也可以完全没有。我正在使用一个自定义格式设置程序,用项目列表填充该单元格,然后用图标删除这些项目

Some text here      X
Some other text     X
And some more       X
单击X图标时,应删除该项目,单击文本时,将下拉列表以选择其他选项

Some text here      X
Some other text     X
Added another line  X   <----removed the previous item and selected a new

如果看不到表构造函数代码的其余部分,就很难告诉您出了什么问题,因为格式化程序中的任何代码都不会导致任何问题。我建议创建一个JS提琴或代码笔来演示这个问题,这样其他人就可以在操作中看到它,而不必看到表构造函数代码的其余部分。很难告诉您出了什么问题,因为格式化程序中的任何代码都不会导致任何问题。我建议创建一个JS提琴或代码笔来演示这个问题,以便其他人可以看到它的实际效果
                        title: "Groups",
                        field: "associatedGroups",
                        variableHeight: true,
                        headerFilter: true,
                        headerFilterPlaceholder: "Search by Group...",
                        formatter: function (cell, formatterParams, onRendered) {
                            var data = [];
                            var newValue = cell.getValue();
                            var oldValue = cell.getOldValue();
                            var newValueIsArray = $.isArray(newValue);
                            var oldValueIsArray = $.isArray(oldValue);

                            if (oldValue !== null && newValue !== null) {
                                if (!oldValueIsArray && newValueIsArray) {
                                    data = data.concat(newValue);
                                    data.unshift(oldValue);
                                } else if (oldValueIsArray && !newValueIsArray) {
                                    data = data.concat(oldValue);
                                    data.push(newValue);
                                } else {
                                    data.push(oldValue);
                                    data.push(newValue);
                                }
                            } else {
                                data = newValue;
                            }

       <!-------------------Value of "data" used here to determine visual layout----------------->

                        },
                        editor: "select",
                        responsive:
                            0,
                        editorParams:
                            {
                                values: groupNames
                            }
                        ,
                        sorter: "string",
                        width:
                            212
                    },