若依点击清空按钮,清空table数据
- 思路:点击清空按钮,触发输入框清空,并且移除列表中所有数据
- 实战:
-
找到ry-ui.js新增restNoRefresh函数,ry-ui.js路径(
src/main/resources/static/ruoyi/js/ry-ui.js
) -
在如图位置添加函数:ps(
搜索“// 表单封装处理”
,在新增函数处添加restNoRefresh函数)
-
代码如下
restNoRefresh: function (formId, tableId) { table.set(tableId); var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId; $("#" + currentId)[0].reset(); if (table.options.type == table_type.bootstrapTable) { if ($.common.isEmpty(tableId)) { $("#" + table.options.id).bootstrapTable('removeAll'); } else { $("#" + tableId).bootstrapTable('removeAll'); } } else if (table.options.type == table_type.bootstrapTreeTable) { if ($.common.isEmpty(tableId)) { $("#" + table.options.id).bootstrapTreeTable('removeAll', []); } else { $("#" + tableId).bootstrapTreeTable('removeAll', []); } } },
-
- 前端页面引用函数(
在页面中重置处引用restNoRefresh函数
)