简体   繁体   English

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

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

I have 100 rows of data, i want to remove selected data based on ID and add new row for that ID. 我有100行数据,我想根据ID删除选定的数据并为该ID添加新行。 I want to edit the rows based on ID. 我想根据ID编辑行。 Here is my code: 这是我的代码:

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;
                    }
                }

I get data in JSON format. 我以JSON格式获取数据。 I want to remove selected rows , it should not affect other rows data. 我要删除选定的行,它不应影响其他行数据。

Simply use WHERE 只需使用WHERE

DELETE FROM DBNAME WHERE ID=XXX 从DBNAME WHERE ID = XXX删除

then Insert into the table with that ID 然后插入具有该ID的表

however, if you want to delete and insert together always, an UPDATE query will work better 但是,如果您想始终删除和插入在一起,则UPDATE查询会更好地工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不删除其他行的情况下向 jquery 中的表添加新的“顶部”行 - How to add a new "top" row to a table in jquery without deleting the other rows 如何在jquery中的选定行的顶部追加新的表行 - How to append new table rows on top of selected row in jquery 如何根据 jQuery 中选定的表行更新表数据? - How to update a table data based on selected table row in jQuery? jQuery 将新行附加到表 - 检测现有行但不添加新行 - jQuery append new row to table - detecting existing rows but not adding new 如何在不影响其他数据的情况下编辑本地存储数据? - How to edit the local storage data without affecting the other data? 如何删除表行到其他行的末尾 - How to remove the table row to the end of other rows jQuery在将数据输入到数量字段时添加新表行 - jQuery add new table row upon entering data into quantity field 达到行限制后自动删除表行,并使用 Websocket 数据和 javascript 向行添加新数据 - Automatically Delete table rows after reaching row limit and add new data to the row using the Websocket data with javascript 如何在不丢失数据和使用不同名称的情况下向表中添加新行? - How can I add new rows to a table without loosing data and with different name? 缩进表的每隔一行而不影响第一行。 HTML / CSS / JS / jQuery的 - Indenting every second row of a table without affecting the first rows. html/css/js/jQuery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM