如何在后面的代码中为具有子树和没有子树的asp树视图的节点设置单独的样式 [英] How to set separate style for a node that has child and no child of asp tree view in code behind

查看:85
本文介绍了如何在后面的代码中为具有子树和没有子树的asp树视图的节点设置单独的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有动态绑定树视图中的品牌,类别和子类别的方案.我对RootNode-品牌,ParentNode-类别和ChildNode- SubCategory有不同的样式.不应单击父节点"和根节点",只能单击子节点.所有这些都可以正常工作,但是我也有一个场景,一个类别可能没有子类别,但是它应该具有父节点样式,也可以单击它.我无法执行此操作.

Hi,

I have scenario which binds the Brand, category and sub categories in a treeview dynamically. I have separate styles for RootNode - Brand, ParentNode - Category and ChildNode- SubCategory. Parent Node and Root node should not be clicked only child nodes can be clicked. All this works fine but I have also a scenario that a Category may not have sub category but it should have parent node style and it can be clicked also. I am not able to do this.

Ex: Brand1
       Category1
           subCategory1.1
           subCategory1.2
       Category2
           subCategory2.1
           subCategory2.2
       Category3
       Category4
       Category5



在上面的示例中,Brand1,Category1和Category2应该不可单击,而只能单击子类别,也可以单击不包含任何子类别的Category. Brand1-应该有一种样式,所有主要类别应该有一种样式,所有子类别都应该有一种样式.



In the above example Brand1,Category1 and Category2 should not be clickable whereas only subcategories can be clicked and Category that does not have any subcategory can also be clicked. Brand1 - should have one style and all the main categories should have one style and all the sub categories should have one style.

推荐答案

您必须使用
.find()

函数.
选中此 jQuery API链接 [

function of jQuery.
Check this jQuery API link[^] for demos.
Just try to add your logic and use this function.
And let me know whether you complete it or not.
Please post your test codes and logic using

.find()

发布您的测试代码和逻辑,以便我为您提供帮助. :)

, so that I can help you. :)



我自己解决了.我已经在运行时创建了树视图控件,并且解决了我的问题.

谢谢大家的支持
Hi,
I have solved it by myself. I have created the treeview controls at runtime and that solved my problem.

Thank you all for your support


这篇关于如何在后面的代码中为具有子树和没有子树的asp树视图的节点设置单独的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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