asp.net1.1下权限配置系统从设计到实现(四)

继续上次的吧,本来还有点瞌睡:) (昨晚的德国VS哥队够精彩),还是坚持写完吧.今天说哈怎么实现Select All  TreeView全部节点的功能?怎么实现展开和折叠自如?
请看:
节点全部选中的实现:
function SelectAllFunctions()
        {          
            
var tree= document.getElementById('<%=tvRoleFunctions.ClientID%>');
            
var chckAll=document.getElementById('<%=chSelectAll.ClientID%>');
            
var NodeArray=tree.getChildren();        
            
for(var i=0;i<NodeArray.length;i++)
            {
                    cNode
=NodeArray[i];
                    
if(chckAll.checked )
                    {
                         cNode.setAttribute('checked',
true);
                         GetSelectedFunctionID(cNode);
                         Checked(cNode);                             
                    }
                    
else
                    {
                     cNode.setAttribute('checked',
false);
                     UnChecked(cNode);
                     }
            }
                    
        }    
function Checked(node)
        {
                
var NodeArray=node.getChildren();
                
for(var i=0;i<NodeArray.length;i++)
                {
                     childNode
=NodeArray[i];
                     childNode.setAttribute('checked',
true);
                }
        }
function UnChecked(node)
        {
                
var NodeArray=node.getChildren();
                
for(var i=0;i<NodeArray.length;i++)
                {
                     cNode
=NodeArray[i];
                     cNode.setAttribute('checked',
false);
                }
            
        }
节点的展开和折叠实现:
//TreeView的节点展开收回
function ExpandAllNodes()
{
   
var tree=document.getElementById('<%=tvRoleFunctions.ClientID%>');
   Expandedall(tree);
}

function CollospaeAllNodes()
{
 
var tree=document.getElementById('<%=tvRoleFunctions.ClientID%>');
 Unexpandedall(tree);
}
function Expandedall(node)
{
        
var i = 0;
        
var nodes = new Array();
        nodes 
= node.getChildren();
        
//alert(nodes.length);
        for(i = 0; i < nodes.length; i++)
        {
            
var cNode;
            cNode
=nodes[i];
            cNode.setAttribute(
"expanded""true");
            
if(parseInt(cNode.getChildren().length) != 0 )
            {
                Expandedall(cNode);
            }
        }
}
function Unexpandedall(node)
{
        
var i = 0;
        
var nodes = new Array();
        nodes 
= node.getChildren();
        
for(i = 0; i < nodes.length; i++)
        {
            
var cNode;
            cNode
=nodes[i];
            
if(parseInt(cNode.getChildren().length) != 0 )
            {
                Unexpandedall(cNode);
            }
            cNode.setAttribute(
"expanded""false");
        }
}
这个怎么调用就不用说了吧!呵呵........
下次写作预告:
在Firefox下TreeView的父子节点联动实现、节点的全部选择和节点的展开和折叠实现.....

posted on 2006-06-10 08:55 kim 阅读(2105) 评论(7)  编辑 收藏 网摘 所属分类: Asp.net开发

评论

#1楼 2006-06-10 10:18 打击者      

可是asp.net 1.1下的TreeView只能从父节点得到子节点 反之不行呀   回复  引用  查看    

#2楼[楼主] 2006-06-10 10:27 kim      

@打击者
可以实现的呀
TreeNode newNode = new TreeNode(); 
if(newNode.Parent !=null

TreeNode Pnode; 
if(newNode.Parent is TreeNode) 

Pnode
=(TreeNode)newNode.Parent; 
if(newNode.Checked ) 

//do somthing 



后面的文章我会写到哈
  回复  引用  查看    

#3楼 2006-06-10 11:18 打击者      

忘记说明了

是在js里面操作

  回复  引用  查看    

#4楼[楼主] 2006-06-10 11:26 kim      

@打击者
见 asp.net1.1下权限配置系统从设计到实现(三)
  回复  引用  查看    

#5楼 2006-06-10 12:28 打击者      

var ParentNode=node.getParent();

这句很纳闷 1.1版本里的treeview.htc里并没有treenode的getParent()方法

<!----------------------------------------------------------------------
// Copyright (c) 2000-2003 Microsoft Corporation. All Rights Reserved.
//---------------------------------------------------------------------->

<public:component tagname=treeview literalcontent=true>
<public:attach event=oncontentready onevent="oncontentready()" />
<public:attach event=ondocumentready onevent="ondocumentready()" />
<public:attach event="onscroll" onevent="onScroll()" />
<public:event name="onexpand" id="_tvevtExpand" />
<public:event name="oncollapse" id="_tvevtCollapse" />
<public:event name="onselectedindexchange" id="_tvevtSelect" />
<public:event name="oncheck" id="_tvevtCheck" />
<public:event name="onfirequeuedevents" id="_tvevtFireQueuedEvents" />
<public:event name="onnodebound" id="_tvevtNodeBound" />
<public:event name="onnodetypesbound" id="_tvevtNodeTypesBound" />
<public:event name="onhover" id="_tvevtHover" />
<public:event name="onunhover" id="_tvevtUnhover" />
<public:property name="clickedNodeIndex" GET="getClickedNodeIndex" />
<public:property name="defaultStyle" id="_tvpropDefaultStyle" GET="getDefaultStyle" PUT="setDefaultStyle" />
<public:property name="hoverStyle" id="_tvpropHoverStyle" GET="getHoverStyle" PUT="setHoverStyle" />
<public:property name="selectedStyle" id="_tvpropSelectedStyle" GET="getSelectedStyle" PUT="setSelectedStyle" />
<public:property name="childType" id="_tvpropChildType" GET="getChildType" PUT="setChildType" />
<public:property name="imageUrl" id="_tvpropImageUrl" GET="getImageUrl" PUT="setImageUrl" />
<public:property name="expandedImageUrl" id="_tvpropExpandedImageUrl" GET="getExpandedImageUrl" PUT="setExpandedImageUrl" />
<public:property name="selectedImageUrl" id="_tvpropSelectedImageUrl" GET="getSelectedImageUrl" PUT="setSelectedImageUrl" />
<public:property name="target" id="_tvpropTarget" GET="getTarget" PUT="setTarget" />
<public:property name="treeNodeSrc" id="_tvpropTreeNodeSrc" GET="getTreeNodeSrc" PUT="setTreeNodeSrc" />
<public:property name="treeNodeXsltSrc" id="_tvpropTreeNodeXsltSrc" GET="getTreeNodeXsltSrc" PUT="setTreeNodeXsltSrc" />
<public:property name="selectExpands" id="_tvpropSelectExpands" GET="getSelectExpands" PUT="setSelectExpands" />
<public:property name="expandLevel" id="_tvpropExpandLevel" GET="getExpandLevel" PUT="setExpandLevel" />
<public:property name="autoSelect" id="_tvpropAutoSelect" GET="getAutoSelect" PUT="setAutoSelect" />
<public:property name="treeNodeTypeSrc" id="_tvpropTreeNodeTypeSrc" GET="getTreeNodeTypeSrc" PUT="setTreeNodeTypeSrc" />
<public:property name="showLines" id="_tvpropShowLines" GET="getShowLines" PUT="setShowLines" />
<public:property name="showPlus" id="_tvpropShowPlus" GET="getShowPlus" PUT="setShowPlus" />
<public:property name="showToolTip" id="_tvpropShowToolTip" GET="getShowToolTip" PUT="setShowToolTip" />
<public:property name="indent" id="_tvpropIndent" GET="getIndent" PUT="setIndent" />
<public:property name="selectedNodeIndex" id="_tvpropSelectedNodeIndex" GET="getSelectedNodeIndex" PUT="setSelectedNodeIndex" />
<public:property name="systemImagesPath" id="_tvpropSystemImagesPath" GET="getSystemImagesPath" PUT="setSystemImagesPath" />
<public:method name="queueEvent" />
<public:method name="getTreeNode" />
<public:method name="addAt" />
<public:method name="createTreeNode" />
<public:method name="getTreeNodeType" />
<public:method name="createTreeNodeType" />
<public:method name="addTreeNodeType" />
<public:method name="add" />
<public:method name="databind" />
<public:method name="databindTypes" />
<public:method name="getChildren" />


</public:component>



按道理应该是你自己扩充了

能贴出代码学习一下吗

谢谢。
  回复  引用  查看    

#6楼 2006-06-19 10:05 main      

如果在系统中用户能够产生自己的子用户,应该如何做啊?感觉大哥做到的是到角色层次,是不是不用考虑下一级用户啊?
还有这个权限东东,是不是要程序员自己制定代号规则啊?比如1对应可以删除这样啊?小弟刚入门,请教!
  回复  引用  查看    

#7楼[楼主] 2006-06-20 08:53 kim      

@main
呵呵,在这个系统中,不用管什么子用户的,只管给角色分配他所需要的权限即可,当我们添加一个新的角色时,实际上我们对角色授权,而不是对用户授权,因为角色和用户是多对多的关系,对用户而言,他只会属于某一个角色组.而与其他没什么关联的.
在这个权限系统中,是通过functionId,functionPointId来实现角色所对应的权限功能的,具体你可以看哈前面几节!特别是那几张表结构.
  回复  引用  查看    




发表评论

昵称: [登录] [注册]

主页:

邮箱:(仅博主可见)

评论内容:

  登录  注册

[使用Ctrl+Enter键快速提交评论]

0 422255




相关文章:

相关链接:

导航

统计

公告

中文: 罗江华
英文: KIM
职务: PL
工作地: 成都/新加坡/美国
MSN: ljhkim6@hotmail.com

---------------------------

我的微软MVP配置
我写/翻译的书



俱乐部:[cdproclub@gmail.com]
网站:http://www.cdpro.com.cn

与我联系

搜索

 

常用链接

留言簿

我参与的团队

随笔分类(202)

随笔档案(159)

文章分类(4)

文章档案(11)

相册

收藏夹(8)

创业

技术网站

我的好友

最新评论