public static void Close_InitTreeGridManual(TreeGrid tg, DataTable dt, int startIndex, int pageSize, string CurrentLanguage) { tg.Nodes.Clear(); TreeGridNode node; TreeGridNode node2; TreeGridNode node3; TreeGridNode node4; DataTable dt_lv1 = dt; DataTable dt_lv2 = order_lv2_bll.GetOrderTable(CurrentLanguage); DataTable dt_lv3 = order_lv3_bll.GetOrderTable(CurrentLanguage); DataTable dt_lv4 = order_lv4_bll.GetOrderTable("", "", CurrentLanguage); int nodeindex = 0; //添加一级订单 foreach (DataRow dr in dt_lv1.Rows) { if (dr["父节点ID"].ToString() == "-1") { var nodevalue = dr["订单ID"].ToString() + ",1"; Foo9 foo = new Foo9(". " + dr["序号"].ToString(), dr["订单ID"].ToString(), dr["订单号"].ToString(), " ", dr["销售类型"].ToString(), dr["订单类型"].ToString(), dr["状态"].ToString(), "", "1"); node = new TreeGridNode(nodevalue); tg.Nodes.Add(node); node.DataItem = foo; node.ToolTip = dr["订单号"].ToString(); node.ImageUrl = "../Images/bill.gif"; node.CollapseAll();//将节点收起 //添加二级订单 foreach (DataRow dr2 in dt_lv2.Rows) { if (dr["订单ID"].ToString() == dr2["父节点ID"].ToString()) { nodevalue = dr2["订单ID"].ToString() + ",2"; string displaytime = dr2["交货日期"].ToString().Trim() == "" ? "" : DateTime.Parse(dr2["交货日期"].ToString()).ToString("yyyy-MM-dd"); foo = new Foo9(". " + dr2["序号"].ToString(), dr2["订单ID"].ToString(), dr2["订单号"].ToString(), displaytime, dr["销售类型"].ToString(), dr["订单类型"].ToString(), dr2["状态"].ToString(), "", "2"); node2 = new TreeGridNode(nodevalue); //tg.Nodes[nodeindex].ChildNodes.Add(node2); node.ChildNodes.Add(node2); node2.DataItem = foo; node2.ImageUrl = "../Images/bill.gif"; node.ImageUrl = "../Images/folder.GIF"; //添加三级订单 foreach (DataRow dr3 in dt_lv3.Rows) { if (dr2["订单ID"].ToString() == dr3["父节点ID"].ToString()) { nodevalue = dr3["订单ID"].ToString() + ",3"; foo = new Foo9(". " + dr3["序号"].ToString(), dr3["订单ID"].ToString(), dr3["订单号"].ToString(), " ", dr["销售类型"].ToString(), dr["订单类型"].ToString(), dr3["状态"].ToString(), dr3["合并状态"].ToString(), "3"); node3 = new TreeGridNode(nodevalue); //tg.Nodes[nodeindex].ChildNodes.Add(node3); node2.ChildNodes.Add(node3); node3.DataItem = foo; node3.ImageUrl = "../Images/bill.gif"; node2.ImageUrl = "../Images/folder.GIF"; //添加四级订单 foreach (DataRow dr4 in dt_lv4.Rows) { if (dr3["订单ID"].ToString() == dr4["父节点ID"].ToString()) { nodevalue = dr4["订单ID"].ToString() + ",4"; foo = new Foo9(". " + dr4["序号"].ToString(), dr4["订单ID"].ToString(), dr4["订单号"].ToString(), " ", dr["销售类型"].ToString(), dr["订单类型"].ToString(), dr4["状态"].ToString(), "", "4"); node4 = new TreeGridNode(nodevalue); //tg.Nodes[nodeindex].ChildNodes.Add(node4); node3.ChildNodes.Add(node4); node4.DataItem = foo; node4.ImageUrl = "../Images/bill.gif"; node3.ImageUrl = "../Images/folder.GIF"; } } } } } } nodeindex++; } } tg.ManualDataBind(); }
public static void InitTreeGridManual(TreeGrid tg) { TreeGridNode node = new TreeGridNode("value_1"); tg.Nodes.Add(node); node.DataItem = GetNodeData(node.Value); node.ToolTip = "tooltip"; node = new TreeGridNode("value_11"); tg.Nodes[0].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node = new TreeGridNode("value_111"); tg.Nodes[0].ChildNodes[0].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_112"); tg.Nodes[0].ChildNodes[0].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_113"); tg.Nodes[0].ChildNodes[0].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_114"); tg.Nodes[0].ChildNodes[0].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_115"); tg.Nodes[0].ChildNodes[0].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_116"); tg.Nodes[0].ChildNodes[0].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_12"); tg.Nodes[0].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node = new TreeGridNode("value_121"); tg.Nodes[0].ChildNodes[1].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_122"); tg.Nodes[0].ChildNodes[1].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_2"); tg.Nodes.Add(node); node.DataItem = GetNodeData(node.Value); node.ToolTip = "tooltip"; node = new TreeGridNode("value_21"); tg.Nodes[1].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_22"); tg.Nodes[1].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_23"); tg.Nodes[1].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_24"); tg.Nodes[1].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_25"); tg.Nodes[1].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_26"); tg.Nodes[1].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node = new TreeGridNode("value_261"); tg.Nodes[1].ChildNodes[5].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_262"); tg.Nodes[1].ChildNodes[5].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_263"); tg.Nodes[1].ChildNodes[5].ChildNodes.Add(node); node.DataItem = GetNodeData(node.Value); node.PopulateOnDemand = true; node = new TreeGridNode("value_3"); tg.Nodes.Add(node); node.DataItem = GetNodeData(node.Value); node.ToolTip = "tooltip"; node.PopulateOnDemand = true; node = new TreeGridNode("value_4"); tg.Nodes.Add(node); node.DataItem = GetNodeData(node.Value); node.ToolTip = "tooltip"; node.PopulateOnDemand = true; tg.ManualDataBind(); }