本文介绍了将firstchildnode left position更改为与其父级相同(treeview)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我一直在努力在一天之内解决这个问题,但仍然无法摆脱它。我已经附上图片来澄清这个问题到我需要的地方。 问题评论 标记视图: < div style =float:left; padding-left:25px> < asp:TreeView ID =ProductLineViewrunat =serverEnableClientScript =truePopulateNodesFromClient =trueClientIDMode =StaticWidth =850pxExpandImageUrl =〜/ App_Themes / PPHPG / Images / plus。 png CollapseImageUrl =〜/ App_Themes / PPHPG / Images / minus.pngOnTreeNodePopulate =ProductLineView_TreeNodePopulate> < NodeStyle CssClass =ProductLineNodeStyleWidth = 850pxNodeSpacing =3.5/> < LeafNodeStyle CssClass =ProductLineLeaftNodeStyleNodeSpacing =1.2/> < / asp:TreeView> < / div> < script type =text / javascript> 功能pageLoad(){ $([id * ='ProductLineViewn'])。each(function(){ var targetid = $(this).attr(Id); if(targetid.indexOf(Nodes)!= -1){ $(this).css({ margin-left:85px , 宽度:765px, margin-bottom:25px, }); } 其他 { $(this).css(padding-right,45px); } }); } < / script> < ; style type =text / css> #ProductLineView { font-size:1.8em; } .ProductLineNodeStyle { margin-left:7px; border:1px solid black; 背景颜色:白色; } .ProductLineLeaftNodeStyle { margin-left:5px; } < / style> 代码背后: var PreviousJobNumber = String.Empty; var NodeCount = 0; dynamic ActiveNode = null; dynamic StepCount = null; var JobDescription = String.Empty; this.ProductLineView.Nodes.Clear(); foreach(查询中的var项目) { dynamic SectionId = null; TreeNode DetailNode; if(PreviousJobNumber!= item.ps_no) { Pr eviousJobNumber = item.ps_no; SectionId = item.Id.ToString(); Int32 SectionValue = Convert.ToInt32(SectionId); JobDescription = timesheet.SectionGroups.Where(p => p.Id == SectionValue).Select(p => p.StockDescription).SingleOrDefault(); TreeNode HeaderNode = new TreeNode(); HeaderNode.Text = item.ps_no ++接收数量++目标数量++< a href =''>访问< / a> ; TreeNode DescriptionNode = new TreeNode(); DescriptionNode.Text = JobDescription; DescriptionNode.Value =Desc; HeaderNode.ChildNodes.Add(DescriptionNode); StepCount = 1; DetailNode = new TreeNode(); DetailNode.Text =(Step+ StepCount +)+ SectionId; DetailNode.Value = SectionId; HeaderNode.ChildNodes.Add(DetailNode); this.ProductLineView.Nodes.Add(HeaderNode); ActiveNode = NodeCount; NodeCount + = 1; } else { StepCount + = 1; SectionId = item.Id.ToString(); DetailNode = new TreeNode(); DetailNode.Text =(Step+ StepCount +)+ SectionId; DetailNode.Value = SectionId; this.ProductLineView .Nodes [ActiveNode] .ChildNodes.Add(DetailNode); } this.ProductLineView.ExpandAll(); } } 非常感谢任何有意思的回复或回答。 我尝试了什么: 我定义了一个边界到节点的整个文本区域,那些服务器控制节点样式似乎只适用于节点区域内的所有内容,但不适用于您定义自己的方式之外。解决方案 ([id * ='ProductLineViewn'])。each(function(){ var targetid = (this).attr( Id); if(targetid.indexOf(Nodes)!= -1){ (this).css({ margin-left:85px, 宽度:765px, margin-bottom:25px , } bb b / b $ I've been struggle to solve this problem in within one day but still unable to get rid on it. I've attached along picture to clarify on this problem to what I need.Problem ReviewMarkup View: <div style="float: left;padding-left:25px"> <asp:TreeView ID="ProductLineView" runat="server" EnableClientScript="true" PopulateNodesFromClient="true" ClientIDMode="Static" Width="850px" ExpandImageUrl="~/App_Themes/PPHPG/Images/plus.png" CollapseImageUrl="~/App_Themes/PPHPG/Images/minus.png" OnTreeNodePopulate="ProductLineView_TreeNodePopulate"> <NodeStyle CssClass="ProductLineNodeStyle" Width="850px" NodeSpacing="3.5" /> <LeafNodeStyle CssClass="ProductLineLeaftNodeStyle" NodeSpacing="1.2" /> </asp:TreeView> </div> <script type="text/javascript"> function pageLoad(){ $("[id*='ProductLineViewn']").each(function () { var targetid = $(this).attr("Id"); if (targetid.indexOf("Nodes") != -1) { $(this).css({ "margin-left": "85px", "width": "765px", "margin-bottom": "25px", }); } else { $(this).css("padding-right","45px"); } }); } </script> <style type="text/css"> #ProductLineView { font-size: 1.8em; } .ProductLineNodeStyle { margin-left:7px; border: 1px solid black; background-color:white; } .ProductLineLeaftNodeStyle { margin-left: 5px; } </style>Code Behind: var PreviousJobNumber = String.Empty; var NodeCount = 0; dynamic ActiveNode = null; dynamic StepCount = null; var JobDescription = String.Empty; this.ProductLineView.Nodes.Clear(); foreach(var item in query) { dynamic SectionId = null; TreeNode DetailNode; if (PreviousJobNumber != item.ps_no) { PreviousJobNumber = item.ps_no; SectionId = item.Id.ToString(); Int32 SectionValue = Convert.ToInt32(SectionId); JobDescription = timesheet.SectionGroups.Where(p => p.Id == SectionValue).Select(p => p.StockDescription).SingleOrDefault(); TreeNode HeaderNode = new TreeNode(); HeaderNode.Text = item.ps_no + " " + "Receive Quantity" + " " + "Target Quantity" + " " + "<a href=''>Access</a>"; TreeNode DescriptionNode = new TreeNode(); DescriptionNode.Text = JobDescription; DescriptionNode.Value = "Desc"; HeaderNode.ChildNodes.Add(DescriptionNode); StepCount = 1; DetailNode = new TreeNode(); DetailNode.Text = "(Step " + StepCount + ") " + SectionId; DetailNode.Value = SectionId; HeaderNode.ChildNodes.Add(DetailNode); this.ProductLineView.Nodes.Add(HeaderNode); ActiveNode = NodeCount; NodeCount += 1; } else { StepCount += 1; SectionId = item.Id.ToString(); DetailNode = new TreeNode(); DetailNode.Text = "(Step " + StepCount + ") " + SectionId; DetailNode.Value = SectionId; this.ProductLineView.Nodes[ActiveNode] .ChildNodes.Add(DetailNode); } this.ProductLineView.ExpandAll(); } }Thanks very to any mindful response or answer.What I have tried:I've define a border to entire text area of nodes and those server control nodestyle seems to be only apply everythings inside the nodes area but not outside where you've to define your own ways. 解决方案 ("[id*='ProductLineViewn']").each(function () { var targetid =(this).attr("Id"); if (targetid.indexOf("Nodes") != -1) {(this).css({ "margin-left": "85px", "width": "765px", "margin-bottom": "25px", }); } else { 这篇关于将firstchildnode left position更改为与其父级相同(treeview)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-14 03:42