public void GetDataItem(int RecordNo, DataItem SourceItem, TreeNodeX SourceNode) { if (FetchRecordNo == null) { logger.Warn("FetchRecordNo FunctionPointer is not set"); return; } logger.Info("Fetching Record No {0}", RecordNo); var dataItem = FetchRecordNo(RecordNo, SourceItem.Schema); if (dataItem == null) { JdSuite.Common.MessageService.ShowError("Data Missing Error", $"Record Id {RecordNo} does not exist in DataFactory"); return; } logger.Info("Fetched DataItem {0}", dataItem.Name); dataItem = dataItem.Children.FirstOrDefault(x => x.Name == SourceItem.Name); if (dataItem == null) { JdSuite.Common.MessageService.ShowError("Data Missing Error", $"Record Id {RecordNo} does not exist in DataFactory"); return; } SourceNode.ClearChildrenNodes(); dataItem.TotalRecordCount = SourceItem.TotalRecordCount; dataItem.ParentGrid = SourceItem.ParentGrid; SourceNode.LoadData(dataItem); RootNode.RemoveDataItem(SourceItem); SourceNode.CurrentRecordNo = RecordNo; TreeNodeX.AdjustColumnWidth(RootNode, true); //LoadData(dataItem); //ShowDataItem(dataItem, RecordNo); }
/// <summary> /// Adds child nodes to parentTreeNode /// </summary> /// <param name="dataItem"></param> /// <param name="parentTreeNode"></param> /// <returns></returns> private TreeNodeX AddChildNode(DataItem dataItem) { TreeNodeX parentTreeNode = this; logger.Trace("Adding_dataNode {0}", dataItem.ToString()); var gridRow = new RowDefinition() { Height = GridLength.Auto }; parentTreeNode.grid.RowDefinitions.Add(gridRow); int rowId = parentTreeNode.grid.RowDefinitions.Count - 1; gridRow.Tag = NodeRowTag; Line line = new Line(); line.Name = "nodeLineHor"; line.StrokeThickness = 1; line.Stroke = Brushes.Blue; line.VerticalAlignment = VerticalAlignment.Top; line.X1 = 0; line.X2 = NodeLineLength; line.Y1 = 10; line.Y2 = 10; Grid.SetColumn(line, 0); Grid.SetRow(line, rowId); //Add line to parent parentTreeNode.grid.Children.Add(line); //Binding binding = new Binding("ActualWidth"); // binding.Source = nodeStackPanel; //binding.Converter = htoPosConverter; // binding.Mode = BindingMode.OneWay; // l.SetBinding(Line.Y1Property, binding); // l.SetBinding(Line.Y2Property, binding); //tn.SetBinding(TreeNodeX.WidthProperty, binding); TreeNodeX childTreeNode = new TreeNodeX(); childTreeNode.DataItem = dataItem; childTreeNode.DataContext = dataItem; childTreeNode.RootNode = parentTreeNode.RootNode; childTreeNode.HorizontalAlignment = HorizontalAlignment.Stretch; childTreeNode.HorizontalContentAlignment = HorizontalAlignment.Stretch; childTreeNode.Margin = new Thickness(ChildNodeLeftMargin, 0, 0, 0); Grid.SetColumn(childTreeNode, 0); Grid.SetRow(childTreeNode, rowId); Grid.SetColumnSpan(childTreeNode, 3); childTreeNode.ParentGridRowNo = rowId; childTreeNode.NodeLine = line; //childTreeNode.textNodeHeader.Text = dataNode.Name; // + "[" + childId + "]"; Remove square bracket as asked by John childTreeNode.CurrentRecordNo = 1; childTreeNode.SetDataNodeBinding(dataItem); dataItem.ParentGrid = parentTreeNode.grid; //Add child node to Parent parentTreeNode.grid.Children.Add(childTreeNode); //Load children and properties for childTreeNode childTreeNode.LoadData(dataItem); childTreeNode.HideNavigationButtons(); if (dataItem.DataType == "Array" && dataItem.Level == 1) { childTreeNode.ShowNavigationButtons(); } /* * if (childTreeNode != childTreeNode.RootNode) * { * childTreeNode.TotalRecordCount = dataNode.ChildCount; * if (dataNode.ChildCount <= 1) * { * //TODO:following may not be correct * childTreeNode.HideNavigationButtons(); * } * * } */ return(childTreeNode); }