本文主要是介绍easyui 选中行在按一次取消选中,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<table id="dg" style="height:100%" ></table>
<script>$(function () {var columns=[{field:'name',title:'菜单名称',width:200,align:'left'},{field:'app',title:'应用名称',width:100,align:'left'},{field:'controller',title:'控制器',width:100,align:'left'},{field:'action',title:'方法',width:100,align:'left'},{field:'menu_type_text',title:'菜单类型',width:100,align:'left'},{field:'is_show',title:'是否显示',width:80,align:'left'},{field:'icon',title:'图标',width:100,align:'left'},{field:'sort',title:'排序',width:100,align:'left',editor:'text'},{field:'remark',title:'备注',width:300,align:'left'}];var toolbar = [{text:'添加菜单',iconCls:'icon-add',handler:function(){var data=g.treegrid('getSelected');var pid;if(!data){pid=0;}else{pid=data.id;}showWindow('菜单添加','{:url("auth/menu_add")}?pid='+pid,800,600,true,function () {//调用父页面的提交方法addFrame.menuSubmit();$('#dg').treegrid('reload');});}},{text:'编辑',iconCls:'icon-edit',handler:function(){var data=g.treegrid('getSelected');if(!data){$.messager.alert('提示','请选择要编辑数据!');return;}showWindow('菜单修改','{:url("auth/menu_edit")}?id='+data.id,800,600,true,function () {//调用父页面的提交方法addFrame.menuSubmit();$('#dg').treegrid('reload');});}},{text:'保存',iconCls:'icon-save',handler:function(){}},'-',{text:'删除',iconCls:'icon-del',handler:function(){var data=g.treegrid('getSelected');if(!data){$.messager.alert('提示','请选择要删除的数据!');return;}$.messager.confirm('提示','确认要删除吗?',function(r){if (r){$.ajax({type:'POST',url:'{:url("auth/menu_del")}',dataType:'json',data:{"id":data.id},error:function (XMLHttpRequest, textStatus, errorThrown) { },success:function(data){layer.msg(data.message);}});}});}}];var IsCheckFlag=false;window['g']=$('#dg').treegrid({url:'{:url("auth/menu")}',method:'post',idField: 'id',treeField: 'name',rownumbers: true,animate:true,collapsible: true,fitColumns: false,columns:[columns],toolbar: toolbar,lines:true,singleSelect : false,checkOnSelect : true,selectOnCheck : true,onSelect: function (row) {if(!IsCheckFlag){IsCheckFlag = true;}else if(row){IsCheckFlag = false;$('#dg').treegrid("unselect",row.id);}else{IsCheckFlag = false;}},onDblClickCell: function (field,row) {$('#dg').treegrid('beginEdit', row.id);// alert(JSON.stringify(row[field]))// $("#dg").treegrid('getEditor',{id:row.id,field:field});}});});</script>
这篇关于easyui 选中行在按一次取消选中的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!