From 0224f58e526178457d79fd5fae41d2ba93b21916 Mon Sep 17 00:00:00 2001 From: Ricky Date: Thu, 30 Sep 2021 15:55:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8B=96=E6=8B=BD=E8=A1=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=94=99=E4=BD=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reorder-rows/bootstrap-table-reorder-rows.js | 16 ++++++++++++++++ .../templates/demo/table/reorderRows.html | 15 ++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.js b/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.js index 6fd7fcc9a..f4abfe154 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.js +++ b/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.js @@ -93,10 +93,26 @@ $.BootstrapTable = class extends $.BootstrapTable { this.options.data.splice(this.options.data.indexOf(draggingRow), 1) this.options.data.splice(index, 0, draggingRow) + this.initSearch() + // Call the user defined function this.options.onReorderRowsDrop(droppedRow) // Call the event reorder-row this.trigger('reorder-row', newData, draggingRow, droppedRow) } + + initSearch () { + this.ignoreInitSort = true + super.initSearch() + } + + initSort () { + if (this.ignoreInitSort) { + this.ignoreInitSort = false + return + } + + super.initSort() + } } diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/reorderRows.html b/ruoyi-admin/src/main/resources/templates/demo/table/reorderRows.html index 2f6bb5efe..e788ccbd2 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/reorderRows.html +++ b/ruoyi-admin/src/main/resources/templates/demo/table/reorderRows.html @@ -5,6 +5,11 @@
+

按住表格行拖拽

@@ -29,7 +34,9 @@ showColumns: false, onReorderRow: function (data) { //当拖拽结束后,data为整个表格的数据 - console.log('拖拽结束' + JSON.stringify(data)) + console.table(data) + // 当sidePagination: "server"时,拖拽行后顺序错乱,需要重新调用加载数据方法 + $("#" + table.options.id).bootstrapTable('load', data); return false; }, columns: [{ @@ -70,6 +77,12 @@ }; $.table.init(options); }); + + /* 查询表格所有数据值 */ + function getData(){ + var data = $("#" + table.options.id).bootstrapTable('getData'); + alert(JSON.stringify(data.map( item => { return item.userId }))) + } \ No newline at end of file