首页 > 解决方案 > 使用选择编辑器时如何在 Tabulator 中触发更新

问题描述

我正在尝试在 Tabulator 中获取选择编辑器的行 ID。我有几百行值,有些我想有一个值是,有些不是。当我更改值时,我需要知道它用于哪一行。这是我的桌子。

              adtable = new Tabulator("#adtable", {
                ajaxURL: "getinfo.php",
                layout: "fitColumns",
                pagination:"local",
                placeholder: "No Data Set available",
                paginationSize: 40,
                paginationSizeSelector: [100, 200, 500, 1000],
                columns: [{
                    title: "Key Name",
                    field: "keyname",
                    formatter: "textarea",
                    sorter: "string",
                    headerFilter: "input"
                  },
                  {
                    title: "Active",
                    field: "display",
                    editor: "select",
                    editorParams: {
                      values: ["Yes", "No"], 
                      sortValuesList: "asc", 
                      defaultValue: "Yes",
                      elementAttributes: {
                        maxlength: "10", 
                      },
                    },
                  ],
                });
            });

我在哪里可以放一个命令,它会给我行号。?我需要更新一个数据库记录。基本上,设置显示=是或否。我的偏好是tickCross,但也无法解决。

非常感谢任何帮助。使用制表符 4.9

标签: selecttabulator

解决方案


想了想……其实很简单。

    {
                title: "Active",
                field: "display",
                editor: "select",
                editorParams: {
                  values: ["Yes", "No"], //create list of values from all values contained in this column
                  sortValuesList: "asc", //if creating a list of values from values:true then choose how it should be sorted
                  defaultValue: "Yes", //set the value that should be selected by default if the cells value is undefined
                  elementAttributes: {
                    maxlength: "10", //set the maximum character length of the input element to 10 characters
                  },
                },
                cellEdited: function(row) {
                  let thisrow = row.getData()
                  alert(thisrow.id + "is  now " + thisrow.display)
                }
              },

在此处添加以帮助可能将头撞到墙上的其他人。我显然在想一些更复杂的事情。


推荐阅读