This is a migrated thread and some comments may be shown as answers.

radorgchart does not fully render until second execution

2 Answers 82 Views
OrgChart
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 19 Apr 2018, 09:16 AM

I have a page on which a user enters a few search criteria via drop down lists, and then searches for org chart results based on those criteria.  I am having a strange issue in which the first time the search button is clicked, the org chart is displayed, but the formatting is wrong, and it's flowing off the screen.

 

See included screen shots of the first time the search button is clicked, and the second time.  Second (and subsequent) search executions all render correctly.

 

  <telerik:RadOrgChart RenderMode="Lightweight" runat="server" ID="RadOrgChart1" OnDataBound="radOrgChartDataBound" Orientation="Vertical" EnableCollapsing="true" EnableDrillDown="false" EnableDragAndDrop="false" EnableGroupCollapsing="true">
 
 
<ItemTemplate>
      <asp:Label runat="server" ID="lblEmployee" Text='<%# DataBinder.Eval(Container.DataItem, "Employee") %>' />
      <asp:Label runat="server" ID="lblAlternate" Text='<%# DataBinder.Eval(Container.DataItem, "ALternate") %>' />
      <asp:HiddenField runat="server" id="hfLead" Value='<%# DataBinder.Eval(Container.DataItem, "TeamLead") %>' />
      <strong><%# DataBinder.Eval(Container.DataItem, "Payroll") %></strong>
</ItemTemplate>
 
  <GroupEnabledBinding>
       <NodeBindingSettings DataFieldID="ID" DataFieldParentID="ParentID" />
       <GroupItemBindingSettings DataFieldID="ID" DataFieldNodeID="NodeID" DataTextField="Employee" />
</GroupEnabledBinding>
 
                                             
<RenderedFields>
     <NodeFields>
          <telerik:OrgChartRenderedField DataField="Text" Label="" />
     </NodeFields>
</RenderedFields>
 
 
</telerik:RadOrgChart>

 

protected void loadOrgChart()
   {
       try
       {
           DataTable dtNodes = new DataTable();
           DataTable dtItems = new DataTable();
 
           if (cnn.State == ConnectionState.Closed) { cnn.Open(); }
           sqlStr = " *** long sql query string here ***  ";
           SqlCommand cmd = new SqlCommand(sqlStr, cnn);
           dtNodes.Load(cmd.ExecuteReader());
           cnn.Close();
 
           if (cnn.State == ConnectionState.Closed) { cnn.Open(); }
           sqlStr = " *** long sql query string here ***  ";
           cmd = new SqlCommand(sqlStr, cnn);
           dtItems.Load(cmd.ExecuteReader());
           cnn.Close();
 
           RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataSource = dtNodes;
           RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataSource = dtItems;
           RadOrgChart1.GroupColumnCount = 1;
 
           for (int i = 0; i < dtNodes.Rows.Count; i++)
           {
               bool hasParent = false;
               string parentID = dtNodes.Rows[i]["ParentID"].ToString();
               for (int j = 0; j < dtNodes.Rows.Count; j++)
               {
                   if (dtNodes.Rows[j]["ID"].ToString() == parentID)
                   {
                       hasParent = true;
                   }
               }
               if (!hasParent)
               {
                   dtNodes.Rows[i]["ParentID"] = DBNull.Value;
               }
           }
 
 
           RadOrgChart1.DataBind();
 
 
       }
       catch (Exception ex)
       {
           lblError.Text = ex.ToString();
       }
 
 
       editSection.Visible = true;
 
       upEditarea.Update();
   }
 
 
 
   protected void radOrgChartDataBound(object sender, EventArgs e)
   {
       RadOrgChart orgChart = RadOrgChart1;
 
 
       foreach (OrgChartNode node in orgChart.GetAllNodes())
       {
 
 
           foreach (OrgChartGroupItem item in node.GroupItems)
           {
               Label lblEmployee = (Label)item.FindControl("lblEmployee");
               Label lblAlternate = (Label)item.FindControl("lblAlternate");
               HiddenField hfLead = (HiddenField)item.FindControl("hfLead");
               if (lblEmployee.Text == "Vacant Position")
               {
                   lblEmployee.ForeColor = System.Drawing.Color.Red;
               }
 
 
               if (hfLead.Value == "True")
               {
                   lblAlternate.Visible = true;
                   if (lblAlternate.Text == "No Alternate")
                   {
                       lblAlternate.ForeColor = System.Drawing.Color.Red;
                   }
               }
               else
               {
                   lblAlternate.Visible = false;
               }
 
 
           }
 
           int nodeLevel = node.Level;
           if (nodeLevel > 0)
           {
               node.Collapsed = true;
 
           }
 
       }
 
   }

 

I'm new to the radorgchart function and using telerik tools in general, so any advice on where I should be looking for the source of this issue is greatly appriciated.

2 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 19 Apr 2018, 09:18 AM
Sorry, forgot to include screen shots.
0
David
Top achievements
Rank 1
answered on 19 Apr 2018, 09:22 AM
Let's try that one more time!
Tags
OrgChart
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Share this question
or