完成layui table点击行选中优化

This commit is contained in:
yubaolee 2025-03-07 09:53:41 +08:00
parent 12d327ddac
commit 4e6287808b
9 changed files with 17 additions and 12 deletions

View File

@ -1,7 +1,7 @@
/* /*
* @Author: yubaolee <yubaolee@163.com> | ahfu~ <954478625@qq.com> * @Author: yubaolee <yubaolee@163.com> | ahfu~ <954478625@qq.com>
* @Date: 2024-11-29 22:16:54 * @Date: 2024-11-29 22:16:54
* @LastEditTime: 2025-03-06 23:29:51 * @LastEditTime: 2025-03-07 09:49:51
* @Description: * @Description:
* Copyright (c) 2025 by yubaolee | ahfu~ , All Rights Reserved. * Copyright (c) 2025 by yubaolee | ahfu~ , All Rights Reserved.
*/ */
@ -61,7 +61,7 @@ layui.define("jquery", function (exports) {
}); });
// 修改laytable点击行选中checkbox // 修改laytable点击行选中checkbox
clickTableRow = function (table, id, filter) { clickTableRow = function (table, id, filter, callback) {
// 监听行单击事件 // 监听行单击事件
table.on('row(' + filter + ')', function (obj) { table.on('row(' + filter + ')', function (obj) {
// 先取消所有行的checkbox的选中状态 // 先取消所有行的checkbox的选中状态
@ -87,7 +87,9 @@ layui.define("jquery", function (exports) {
// 设置当前行checkbox 选中 // 设置当前行checkbox 选中
obj.tr.find('input[type="checkbox"]').prop('checked', true); obj.tr.find('input[type="checkbox"]').prop('checked', true);
obj.data.LAY_CHECKED = true; obj.data.LAY_CHECKED = true;
if (callback) {
callback(obj);
}
}); });
} }

View File

@ -102,6 +102,7 @@ layui.config({
}; };
}(); }();
clickTableRow(table,'mainList', 'list');
//监听表格内部按钮 //监听表格内部按钮
table.on('tool(list)', function (obj) { table.on('tool(list)', function (obj) {
var data = obj.data; var data = obj.data;

View File

@ -68,7 +68,7 @@
}(); }();
$("#tree").height($("div.layui-table-view").height()); $("#tree").height($("div.layui-table-view").height());
clickTableRow(table,'mainList', 'list');
//监听表格内部按钮 //监听表格内部按钮
table.on('tool(list)', function (obj) { table.on('tool(list)', function (obj) {
var data = obj.data; var data = obj.data;

View File

@ -68,7 +68,7 @@
}(); }();
$("#tree").height($("div.layui-table-view").height()); $("#tree").height($("div.layui-table-view").height());
clickTableRow(table,'mainList', 'list');
//监听表格内部按钮 //监听表格内部按钮
table.on('tool(list)', function (obj) { table.on('tool(list)', function (obj) {
var data = obj.data; var data = obj.data;

View File

@ -108,6 +108,7 @@
}; };
}(); }();
clickTableRow(table,'mainList', 'list');
//监听表格内部按钮 //监听表格内部按钮
table.on('tool(list)', function (obj) { table.on('tool(list)', function (obj) {
var data = obj.data; var data = obj.data;

View File

@ -109,6 +109,7 @@
}; };
}(); }();
clickTableRow(table,'mainList', 'list');
//监听表格内部按钮 //监听表格内部按钮
table.on('tool(list)', function (obj) { table.on('tool(list)', function (obj) {
var data = obj.data; var data = obj.data;

View File

@ -109,6 +109,7 @@
}; };
}(); }();
clickTableRow(table,'mainList', 'list');
//监听表格内部按钮 //监听表格内部按钮
table.on('tool(list)', function (obj) { table.on('tool(list)', function (obj) {
var data = obj.data; var data = obj.data;

View File

@ -62,6 +62,9 @@ layui.config({
} }
}); });
} }
clickTableRow(table,'mainList', 'list', function (obj) {
menuList({moduleId: obj.data.Id});
});
//菜单列表 //菜单列表
var menucon = {}; //table的参数如搜索key点击tree的id var menucon = {}; //table的参数如搜索key点击tree的id
var menuList = function (options) { var menuList = function (options) {
@ -212,11 +215,6 @@ layui.config({
}; };
}(); }();
clickTableRow(table,'mainList', 'list');
//监听行单击事件
table.on('row(list)', function (obj) {
menuList({moduleId: obj.data.Id});
});
//监听页面主按钮操作 //监听页面主按钮操作
var active = { var active = {

View File

@ -35,6 +35,7 @@
}); });
}; };
mainList(); mainList();
clickTableRow(table,'mainList', 'list');
//添加(编辑)对话框 //添加(编辑)对话框
var editDlg = function () { var editDlg = function () {