如何在不影响 Jquery 数据表中其他行的情况下删除选定的现有数据并添加新行

How to remove selected existing data and add new row without affecting other rows in Jquery data table

本文关键字:删除 数据 新行 添加 情况下 影响 Jquery 数据表 其他      更新时间:2023-09-26

我有 100 行数据,我想根据 ID 删除选定的数据并为该 ID 添加新行。我想根据 ID 编辑行。这是我的代码:

oCustomization : {
            sExportFunctionCall : oMapUrls.exportLiveFleetReport,
            bAdvanceExport : true,
            bShowDefaultAll : !bLivePaginate
        },
        pageLength : !bLivePaginate ? -1 : Global.rowLength,
        scrollCollapse : false,
        scrollY : iDataTableHeight,
        serverSide : bLivePaginate,
        order : [ [ 3, "desc" ] ],
        columns : [
                {
                    "data" : "trackeeName",
                    "width" : aColumnWidths[0],
                    "class" : "no-word-break",
                    "settings" : {
                        source : function(request, oCallback) {
                            oCallback($.ui.autocomplete.filter(Global.aJSTreeVehicleItems || [], request.term));
                        }
                    },
                    "render" : function(value, type, rowData) {
                      //Some code here
                    }
                },
                {
                    "data" : "firstName",
                    "width" : aColumnWidths[1],
                    "class" : "no-word-break",
                    settings : {
                        source : Global.getDriverSuggestion
                    },
                    "title" : jQuery.i18n.prop("driver.title.txtInfo"),
                    "visible" : Global['show.driver.in.reports'] == 1,
                    "render" : function(value, type, rowData) {
                        return getUserName(rowData.firstName, rowData.lastName);
                    }
                },
                {
                    "data" : "groupName",
                    "width" : aColumnWidths[2],
                    "class" : "no-word-break",
                    "settings" : {
                        source : function(request, oCallback) {
                           oCallback($.ui.autocomplete.filter(Global.aJSTreeGroupItems || [], request.term));
                        }
                    },
                    "title" : jQuery.i18n.prop("vehicle.col2label")
                },
                {
                    "data" : "dateAndTime",
                    "width" : aColumnWidths[3],
                    "searchable" : !bLivePaginate,
                    "class" : "wordBreak",
                    "title" : jQuery.i18n.prop("report.columnTitle.date"),
                    "render" : function(value, type, rowData) {
                        if (type == "display") {
                            return rowData.formattedDate;
                        }
                        return value;
                    }
                }

我以 JSON 格式获取数据。我想删除选定的行,它应该不会影响其他行数据。

只需使用 WHERE

从 ID = XXX 的数据库名称中删除

然后使用该 ID 插入到表中

但是,如果要始终删除并一起插入,则 UPDATE 查询会更好