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事件了

  • 相关阅读:
    git remote和git clone新项目后如何拉取分支代码到本地
    PHP 文件上传
    PHP 小学生99乘法表
    PHP 递归删除目录
    PHP 如何封装水印函数
    【转】设计模式六大原则(1):单一职责原则
    ubuntu 下安装 activate-power-mode
    ubuntu中使用virtualbox遇到Kernel driver not installed (rc=-1908)错误
    【转】使用SQL语句创建和删除约束
    ORA-02291:parent key not found
  • 原文地址:https://www.cnblogs.com/dreamcat/p/7372985.html
Copyright © 2011-2022 走看看