树视图 - 选择的节点样式不出现所选节点 [英] TreeView — selected node style doesn't appears to selected node
问题描述
我的code是:
< ASP:TreeView的ID =TreeViewCategories=服务器ExpandDepth =0样式=最小高度:200像素;
最大高度:500像素,LineImagesFolder =〜/ TreeLineImagesNodeIndent =0LeafNodeStyle-的CssClass =LeafNodesStyle
的CssClass =树视图NodeStyle-的CssClass =NodeStyleParentNodeStyle-的CssClass =ParentNodeStyle
RootNodeStyle-的CssClass =RootNodeStyleSelectedNodeStyle-的CssClass =SelectedNodeStyle
LeafNodeStyle-WIDTH =100%NodeStyle-WIDTH =100%ParentNodeStyle-WIDTH =100%
RootNodeStyle-WIDTH =100%FONT-SIZE =12磅>
<&节点GT;
< ASP:树节点文本=所有物品SelectAction =展开PopulateOnDemand =真值=全部项目/>
< /节点>
< / ASP:TreeView的>
CSS
.TreeView
{
下边框:1px的虚线#B2B2B2重要;!
}.TreeView DIV
{
保证金左:5像素;
}.TreeView表
{
边境顶:1px的虚线#B2B2B2重要;!
}.TreeView格表
{
下边框:无重要;
边境顶:无重要;
}.TreeView表TD
{
填充:2px的0;
}.LeafNodesStyle
{}.RootNodeStyle
{}/ *所有元素* /.NodeStyle
{}.ParentNodeStyle
{
/ *背景:黄色; * /
}.SelectedNodeStyle {字体重量:大胆的;颜色:#6799D1;显示:块;填充:2px的2px的0的3px; }
让我看到(与萤火虫)为我选择的节点出现访问款式,风格的节点,叶风格,但没有选择节点的风格:(
如何解决这个HTML / CSS / ASP做出选择的节点大胆和蓝例如?
感谢您。
补充道:添加节点喜欢这里:
的foreach(C:在rootCategories类别)
{
可变newNode:树节点=树节点(c.Title,c.Id);
newNode.SelectAction = TreeNodeSelectAction.SelectExpand;
newNode.NavigateUrl =Items.aspx CATID =?+ c.Id.ToString()+&放大器; LVL = 0;
与解决...
的categoryId:字符串=的Request.QueryString [CATID];
N:树节点= findNode(的categoryId,TreeViewCategories.Nodes,LVL);
n.Selected = TRUE;
在的 SelectAction 的在属性的 ASP:树节点的是展开箭塔为 SelectExpand 的搜索结果
这可确保有一个回传,树重绘控件应用您在树视图设置seleceted节点风格
< ASP:TreeView的ID =TreeViewCategories=服务器ExpandDepth =0样式=最小高度:200像素;
最大高度:500像素,LineImagesFolder =〜/ TreeLineImagesNodeIndent =0LeafNodeStyle-的CssClass =LeafNodesStyle
的CssClass =树视图NodeStyle-的CssClass =NodeStyleParentNodeStyle-的CssClass =ParentNodeStyle
RootNodeStyle-的CssClass =RootNodeStyleSelectedNodeStyle-的CssClass =SelectedNodeStyle
LeafNodeStyle-WIDTH =100%NodeStyle-WIDTH =100%ParentNodeStyle-WIDTH =100%
RootNodeStyle-WIDTH =100%FONT-SIZE =12磅>
<&节点GT;
< ASP:树节点文本=所有物品SelectAction =SelectExpandVALUE =所有项目>
< ASP:树节点文本=所有物品SelectAction =SelectExpandVALUE =所有项目/>
< ASP:树节点文本=所有物品SelectAction =SelectExpandVALUE =所有项目/>
< ASP:树节点文本=所有物品SelectAction =SelectExpandVALUE =所有项目/>
< / ASP:树节点>
< /节点>
< / ASP:TreeView的>
My code is :
<asp:TreeView ID="TreeViewCategories" runat="server" ExpandDepth="0" Style="min-height: 200px;
max-height: 500px;" LineImagesFolder="~/TreeLineImages" NodeIndent="0" LeafNodeStyle-CssClass="LeafNodesStyle"
CssClass="TreeView" NodeStyle-CssClass="NodeStyle" ParentNodeStyle-CssClass="ParentNodeStyle"
RootNodeStyle-CssClass="RootNodeStyle" SelectedNodeStyle-CssClass="SelectedNodeStyle"
LeafNodeStyle-Width="100%" NodeStyle-Width="100%" ParentNodeStyle-Width="100%"
RootNodeStyle-Width="100%" Font-Size="12pt">
<Nodes>
<asp:TreeNode Text="All Items" SelectAction="Expand" PopulateOnDemand="True" Value="All Items" />
</Nodes>
</asp:TreeView>
css
.TreeView
{
border-bottom:1px dotted #B2B2B2 !important;
}
.TreeView div
{
margin-left:5px;
}
.TreeView table
{
border-top:1px dotted #B2B2B2 !important;
}
.TreeView div table
{
border-bottom:none !important;
border-top:none !important;
}
.TreeView table td
{
padding:2px 0;
}
.LeafNodesStyle
{
}
.RootNodeStyle
{
}
/* ALL ELEMENTS */
.NodeStyle
{
}
.ParentNodeStyle
{
/*background:yellow;*/
}
.SelectedNodeStyle { font-weight: bold; color:#6799D1; display:block; padding:2px 0 2px 3px; }
so I see (with firebug) for my selected node appears Visited style , node style , leaf style but not Selected node style :(
How to fix this HTML/CSS/ASP to make selected node Bold and Blue for example ?
Thank you.
added : adding nodes like here :
foreach(c : Category in rootCategories)
{
mutable newNode : TreeNode = TreeNode(c.Title, c.Id);
newNode.SelectAction = TreeNodeSelectAction.SelectExpand;
newNode.NavigateUrl = "Items.aspx?catId=" + c.Id.ToString() + "&lvl=0";
solved with...
categoryId : string = Request.QueryString["catId"];
n : TreeNode = findNode(categoryId, TreeViewCategories.Nodes, lvl);
n.Selected = true;
The SelectAction attribute on the asp:TreeNode is Expand change it to SelectExpand.
This ensures that there is a postback and the tree control is redrawn to apply the seleceted node style that you set on the treeview
<asp:TreeView ID="TreeViewCategories" runat="server" ExpandDepth="0" Style="min-height: 200px;
max-height: 500px;" LineImagesFolder="~/TreeLineImages" NodeIndent="0" LeafNodeStyle-CssClass="LeafNodesStyle"
CssClass="TreeView" NodeStyle-CssClass="NodeStyle" ParentNodeStyle-CssClass="ParentNodeStyle"
RootNodeStyle-CssClass="RootNodeStyle" SelectedNodeStyle-CssClass="SelectedNodeStyle"
LeafNodeStyle-Width="100%" NodeStyle-Width="100%" ParentNodeStyle-Width="100%"
RootNodeStyle-Width="100%" Font-Size="12pt">
<Nodes>
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items">
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items" />
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items" />
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items" />
</asp:TreeNode>
</Nodes>
</asp:TreeView>
这篇关于树视图 - 选择的节点样式不出现所选节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!