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

  • 相关阅读:
    谷歌浏览器解决跨域
    实现Linux共享Window文件
    linux安装显卡驱动
    jsduck 文档生成器
    linux 笔记
    Linux phpstorm 无法输入中文
    linux 安装composer
    Extjs动态生成表头(适用报表)
    关于git的配置与使用
    JSP解决中文乱码问题
  • 原文地址:https://www.cnblogs.com/dreamcat/p/7372985.html
Copyright © 2011-2022 走看看