zoukankan      html  css  js  c++  java
  • easy-ui 中的事件触发 (tree)

    easy-ui可以为插件添加事件,但没有触发事件的处理(可能是未找到),所以有时候,我们需要通过程序去触发某个插件指定的事件时,就一筹莫展了

    以Tree插件为例 ,添加了onClick事件

    jQuery("#tree_syscode_" + item.ValueCode).tree({
    					method : 'get',
    					url : String
    							.format(
    									"/tools/ajax.aspx?ac=GetSystemCodeTree&type={0}&r={1}",
    									item.ValueCode, Math.random()),
    					lines : true,
    					onClick : function(node) {...}
    });
    

      

    可能我们需要在数据加载完成后,自动加载第一个树形节点关联的数据

    jQuery("#tree_syscode_" + item.ValueCode).tree({
    					method : 'get',
    					url : String
    							.format(
    									"/tools/ajax.aspx?ac=GetSystemCodeTree&type={0}&r={1}",
    									item.ValueCode, Math.random()),
    					lines : true,
    					onClick : function(node) {
    						...
    					},
    					onLoadSuccess : function(node, data) {
    						if (data.length == 0) {
    							return;
    						}
    
    						// 首次加载时,node为null
    						if (node == null) {
    							...
    							// 这儿是初始化Tree的的处理,需要触发Tree.onClick
    						}
    					}
    				});
    

     此时就需要触发Tree的onClick事件了,但easyui没有添加事件直接调用的方法,那么我们变通一下,通过options方法得到Tree绑定的事件

     

    jQuery("#tree_syscode_" + item.ValueCode).tree({
    					method : 'get',
    					url : String
    							.format(
    									"/tools/ajax.aspx?ac=GetSystemCodeTree&type={0}&r={1}",
    									item.ValueCode, Math.random()),
    					lines : true,
    					onClick : function(node) {
    						...
    					},
    					onLoadSuccess : function(node, data) {
    						if (data.length == 0) {
    							return;
    						}
    
    						// 首次加载时,node为null
    						if (node == null) {
    							var s_node = $(this).tree('find', data[0].id);
    							var func = $(this).tree('options').onClick;
    
    							if (func != null) {
    								func.call(this, s_node);
    							}
    						}
    					}
    				});
    

      这样就可以触发Click事件了

  • 相关阅读:
    java的应用项目
    项目评审ppt的纲要
    Spark环境搭建
    spark 环境搭建坑
    redis cluster 实现
    hadoop环境搭建编译
    centos 网络配置
    自定义shell开头PS1
    Centos. Mac 通过nfs 搭建共享目录
    mac系统中实现vitualBox中访问内网端口
  • 原文地址:https://www.cnblogs.com/dreamcat/p/7372985.html
Copyright © 2011-2022 走看看