Browse Source

新增表格行触发事件(onCheck、onUncheck、onCheckAll、onUncheckAll)

RuoYi 4 years ago
parent
commit
cefb14e521

+ 4 - 0
ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js

@@ -116,6 +116,10 @@ var table = {
                     mobileResponsive: options.mobileResponsive,         // 是否支持移动端适配
                     cardView: options.cardView,                         // 是否启用显示卡片视图
                     detailView: options.detailView,                     // 是否启用显示细节视图
+                    onCheck: options.onCheck,                           // 当选择此行时触发
+                    onUncheck: options.onUncheck,                       // 当取消此行时触发
+                    onCheckAll: options.onCheckAll,                     // 当全选行时触发
+                    onUncheckAll: options.onUncheckAll,                 // 当取消全选行时触发
                     onClickRow: options.onClickRow,                     // 点击某行触发的事件
                     onDblClickRow: options.onDblClickRow,               // 双击某行触发的事件
                     onClickCell: options.onClickCell,                   // 单击某格触发的事件

+ 26 - 0
ruoyi-admin/src/main/resources/templates/demo/table/event.html

@@ -24,6 +24,10 @@
 		        showRefresh: false,
 		        showToggle: false,
 		        showColumns: false,
+		        onCheck: onCheck,
+		        onUncheck: onUncheck,
+		        onCheckAll: onCheckAll,
+		        onUncheckAll: onUncheckAll,
 		        onClickRow: onClickRow,
 		        onDblClickRow: onDblClickRow,
 		        onClickCell: onClickCell,
@@ -95,6 +99,28 @@
         	alert("双击格name:" + field + " value:" + value);
         }
         
+        function onCheck(row, $element){
+        	alert("选中行userId:" + row.userId + " userName:" + row.userName);
+        }
+        
+        function onUncheck(row, $element){
+        	alert("取消行userId:" + row.userId + " userName:" + row.userName);
+        }
+        
+        function onCheckAll(rowsAfter, rowsBefore){
+        	var rows = $.map(rowsAfter, function(row) {
+    	        return $.common.getItemField(row, "userId");
+    	    });
+        	alert("全选行:" + rows);
+        }
+        
+        function onUncheckAll(rowsAfter, rowsBefore){
+        	var rows = $.map(rowsBefore, function(row) {
+    	        return $.common.getItemField(row, "userId");
+    	    });
+        	alert("取消行:" + rows);
+        }
+        
         function responseHandler(res){
         	alert("请求获取数据后处理回调函数");
         }