treeview按需填充更改treenode图像客户端(javascript) [英] treeview populate on demand change treenode image clientside (javascript)

查看:90
本文介绍了treeview按需填充更改treenode图像客户端(javascript)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的简单问题如下:

当我按需填充Treeview时,我想在当前正在填充的treenode上显示一种正在进行的图标.

我为此找到了我非常喜欢的解决方案:

My simple problem is the following:

When I populate my Treeview on demand I want to show a sort of an in progress icon on the treenode currently beeing populated.

I Found for that the solution that I btw like very much:

function OnExpandClick(event)
{

    var evt = evt || window.event; // event object
    var obj = evt.target || window.event.srcElement; // event target

    if (obj.tagName.toLowerCase() == "img" || obj.tagName.toLowerCase() == "a") {

        obj.src = "../secure/pictures/loading.gif";
        //selectedNode = document.getElementById(obj.id);
        obj.alt = "Loading ...";
    }
}



这里发生的是,当我单击要扩展的treenode的folderIcon时,它显示了一个小的进度图标..

但是这里是问题所在:当我单击treenode文本时,在



what happens here is that when I click on the folderIcon of the treenode I want to expand.. it shows a small progressing Icon..

BUT here is the problem: WHEN I click on the treenode text, in the

<a ...="" />

标签.我想显示相同的图标..但在这种情况下,请看上面的javascript代码.obj.变量simple不包含src或图像url元素..

我了解到treenode是作为
建立的

tag. I want to show the same icon.. but looking at the javascript code above.. in that scenario the obj. variable simple does not contain a src or image url element..

I learned that a treenode is build up as

<table><tbody><tr>
<td>
<a> treenode name etc</a>
<IMG>
</td>
</tr></tbody></table>



请任何人启发我从A标记开始点击时如何访问IMG ..

任何想法或建议都是最欢迎的!预先感谢.



Please anyone enlighten me on how to acces the IMG when the click is comming from the A tag..

Any ideas or suggestions are most welcome!! Thanks in advance.

推荐答案

使用JQuery,这真的非常简单

选择所有作为表元素后代的锚元素
With JQuery this is really very simple

Select all anchor elements that are descendants of a table element


("table a").click(function() // Do something on click });
("table a").click(function() // Do something on click });



如果要更精确,请使用表格的ID



If you want to be more precise use the ID of the table


("#tableID a").click(function() // Do something on click });
("#tableID a").click(function() // Do something on click });



您可以对图像标签执行相同的操作,也可以从锚点同级进行操作.



You can do the same thing with the image tags, or get to it from the anchor sibling.


这篇关于treeview按需填充更改treenode图像客户端(javascript)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆