hierarchy grid issue

8 posts, 0 answers
  1. Chris
    Chris avatar
    3 posts
    Member since:
    Nov 2013

    Posted 29 Mar 2014 Link to this post

    Hi,
    When I set the hierarchyloadmode to client I am having a strange issue. The first row is supposed to have one detail table row but it has over 50 blank ones. The problem only seems to happen for the first row of the master table, the rest are fine. When I set the mode back to default, the issue is not there. Has anyone else seen this?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 01 Apr 2014 in reply to Chris Link to this post

    Hi Chris,

    Its hard to identify the issue with so less information. Please provide your full code snippet, meanwhile take a look at the sample code snippet which works as expected at my end.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" RetainExpandStateOnRebind="true" AllowPaging="True" AllowMultiRowSelection="true" AllowSorting="true" OnDetailTableDataBind="RadGrid1_DetailTableDataBind"
        OnNeedDataSource="RadGrid1_NeedDataSource">
        <MasterTableView DataKeyNames="CustomerID" HierarchyLoadMode="Client" Name="Customers">
            <DetailTables>
                <telerik:GridTableView DataKeyNames="OrderID" Name="Orders">
                    <Columns>
                        <telerik:GridBoundColumn SortExpression="OrderID" HeaderText="OrderID" DataField="OrderID">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn SortExpression="OrderDate" HeaderText="Date Ordered" DataField="OrderDate" UniqueName="OrderDate" DataFormatString="{0:D}">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn SortExpression="Freight" HeaderText="Freight" DataField="Freight" UniqueName="Freight">
                        </telerik:GridBoundColumn>
                    </Columns>
                </telerik:GridTableView>
            </DetailTables>
            <Columns>
                <telerik:GridBoundColumn SortExpression="CustomerID" HeaderText="CustomerID" DataField="CustomerID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn SortExpression="ContactName" HeaderText="Contact Name" DataField="ContactName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn SortExpression="CompanyName" HeaderText="Company" DataField="CompanyName">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings AllowExpandCollapse="true">
        </ClientSettings>
    </telerik:RadGrid>

    C#:
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        if (!e.IsFromDetailTable)
        {
            RadGrid1.DataSource = GetDataTable("Select * from Customers");
        }
    }
     
    protected void RadGrid1_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
    {
        GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
        switch (e.DetailTableView.Name)
        {
            case "Orders":
              {
                string CustomerID = dataItem.GetDataKeyValue("CustomerID").ToString();
                e.DetailTableView.DataSource = GetDataTable("SELECT * FROM Orders WHERE CustomerID = '" + CustomerID + "'");
                break;
              }
        }
    }
     
    public DataTable GetDataTable(string query)
    {
        String ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(ConnString);
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand(query, conn);
     
        DataTable myDataTable = new DataTable();
     
        conn.Open();
        try
        {
            adapter.Fill(myDataTable);
        }
        finally
        {
            conn.Close();
        }
        return myDataTable;
    }

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Saktheeswaran
    Saktheeswaran avatar
    7 posts
    Member since:
    Feb 2014

    Posted 19 May 2014 Link to this post

    Hi Princy,

    In my grid have hierarchy option. Like Product and order details. In my grid have 'Product 1'  to  ' Product 10' in product grid and the child grid have the order details of the product.

    Some product don't have a order details. that time there are no child grid.

    At the time I don't need the Expand (image) column in my grid

    Thanks
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 May 2014 in reply to Saktheeswaran Link to this post

    Hi Saktheeswaran,

    Please take a look at this documentation for your requirement.
    Hiding the expand/collapse images when no records

    Thanks,
    Princy
  6. Saktheeswaran
    Saktheeswaran avatar
    7 posts
    Member since:
    Feb 2014

    Posted 20 May 2014 in reply to Princy Link to this post

    Hi Princy,

    Thanks for fast reply.

    It's hide all the Expand image. But I need what the records have child then it show the expand other wise no need to show expand image.

    See the attached image. The first row have a child so we need to show the expand arrow. and the second row dont have a child record. now we are hide the expand image.

    Thanks
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 May 2014 in reply to Saktheeswaran Link to this post

    Hi Saktheeswaran,

    Please set HierarchyLoadMode="Client" and check if the Expand button hides.

    ASPX:
    <MasterTableView HierarchyLoadMode="Client">
        <DetailTables>
            <telerik:GridTableView HierarchyLoadMode="Client">

    Thanks,
    Princy
  8. Saktheeswaran
    Saktheeswaran avatar
    7 posts
    Member since:
    Feb 2014

    Posted 01 Sep 2014 Link to this post

    Hi Princy,

    I have one more issue in hierarchy grid. In my grid have three level of hierarchy grid. Now I need to change the Header text in each grid level. But I am not able to do this. Can you pls help.

    My Code.
    ASPX:
    ---------
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
                    <telerik:RadGrid ID="RdGridDeleteSample" runat="server" Width="100%" ShowStatusBar="True"
                        AutoGenerateColumns="False" PageSize="15" AllowSorting="True" AllowPaging="True"
                        AllowFilteringByColumn="True" CssClass="mytelGrid" Font-Names="Tahoma" OnItemCreated="RdGridDeleteSample_ItemCreated"
                        OnDetailTableDataBind="RdGridDeleteSample_DetailTableDataBind" OnNeedDataSource="RdGridDeleteSample_NeedDataSource"
                        OnPreRender="RdGridDeleteSample_PreRender" OnItemCommand="RdGridDeleteSample_ItemCommand">
                        <GroupingSettings CaseSensitive="false"></GroupingSettings>
                        <ClientSettings Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true">
                            <Resizing AllowColumnResize="True" AllowRowResize="false" ResizeGridOnColumnResize="false"
                                ClipCellContentOnResize="true" EnableRealTimeResize="false" AllowResizeToFit="true" />
                        </ClientSettings>
                        <MasterTableView Width="100%" DataKeyNames="AccountId" AllowMultiColumnSorting="True">
                            <DetailTables>
                                <telerik:GridTableView DataKeyNames="ComponentRef" Name="HistoryAccount" Width="100%"
                                    BorderWidth="2px" BorderStyle="Solid" BorderColor="#1f1ffe">
                                    <DetailTables>
                                        <telerik:GridTableView EnableHierarchyExpandAll="true" Width="100%" Name="HistoryComponent"
                                            runat="server">
                                            <Columns>
                                                <telerik:GridBoundColumn HeaderText="Sample_id" DataField="Sample_id" SortExpression="Sample_id"
                                                    HeaderButtonType="TextButton" Display="false" />
                                                <telerik:GridBoundColumn HeaderText="CustomerSampleRef" DataField="CustomerSampleRef"
                                                    SortExpression="CustomerSampleRef" HeaderButtonType="TextButton" Display="false" />
                                                <telerik:GridBoundColumn HeaderText="CompID" DataField="CompID" SortExpression="CompID"
                                                    HeaderButtonType="TextButton" Display="false" />
                                                <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this sample?" UniqueName="Delete"
                                                    HeaderText="Delete" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton"
                                                    ImageUrl="../Images/Griddelete.png" CommandName="Delete" Resizable="True" ItemStyle-Height="10px">
                                                </telerik:GridButtonColumn>
                                                <telerik:GridBoundColumn FilterControlWidth="100px" HeaderText="Last Sample" DataField="LastSample"
                                                    SortExpression="LastSample" HeaderButtonType="TextButton">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn FilterControlWidth="70px" HeaderText="Analysis Mode" DataField="AnalysisMode"
                                                    SortExpression="AnalysisMode" HeaderButtonType="TextButton" />
                                                <telerik:GridBoundColumn FilterControlWidth="70px" HeaderText="Sample Condition" UniqueName="SampleCondition"
                                                    DataField="LastCondition" SortExpression="LastCondition" HeaderButtonType="TextButton" />
                                                <telerik:GridDateTimeColumn PickerType="DatePicker" DataFormatString="{0:d}" CurrentFilterFunction="EqualTo"
                                                    ShowFilterIcon="false" AutoPostBackOnFilter="true" FilterDateFormat="MM/dd/yyyy"
                                                    EnableRangeFiltering="false" FilterControlWidth="70px" HeaderText="Last Sample Date" UniqueName="LastSampleDate"
                                                    DataField="LastSampleDate" SortExpression="LastSampleDate" HeaderButtonType="TextButton" />
                                                <telerik:GridDateTimeColumn PickerType="DatePicker" DataFormatString="{0:D}" EnableRangeFiltering="false" UniqueName="PostedDate"
                                                    ShowFilterIcon="false" FilterControlWidth="70px" HeaderText="Posted Date" DataField="PostedDate"
                                                    SortExpression="PostedDate" HeaderButtonType="TextButton" />
                                            </Columns>
                                        </telerik:GridTableView>
                                    </DetailTables>
                                    <Columns>
                                        <telerik:GridBoundColumn HeaderText="TypeId" DataField="TypeId" SortExpression="TypeId"
                                            HeaderButtonType="TextButton" Display="false" />
                                        <telerik:GridBoundColumn HeaderText="AccountId" DataField="AccountId" SortExpression="AccountId"
                                            HeaderButtonType="TextButton" Display="false" />
                                        <telerik:GridBoundColumn HeaderText="CompID" DataField="CompID" SortExpression="CompID"
                                            HeaderButtonType="TextButton" Display="false" />
                                        <telerik:GridBoundColumn HeaderText="UnitRef" DataField="UnitRef" SortExpression="UnitRef"
                                            Visible="false" HeaderButtonType="TextButton" />
                                        <telerik:GridBoundColumn HeaderText="CustUnitId" DataField="CustUnitId" SortExpression="CustUnitId" UniqueName="CustUnitId"
                                            HeaderButtonType="TextButton" />
                                        <telerik:GridBoundColumn HeaderText="UnitMake" DataField="UnitMake" SortExpression="UnitMake" UniqueName="UnitMake"
                                            HeaderButtonType="TextButton" />
                                        <telerik:GridBoundColumn HeaderText="UnitModel" DataField="UnitModel" SortExpression="UnitMakeModel" UniqueName="UnitMakeModel"
                                            HeaderButtonType="TextButton" />
                                        <telerik:GridBoundColumn HeaderText="ComponentRef" DataField="ComponentRef" SortExpression="ComponentRef" UniqueName="ComponentRef"
                                            Visible="false" HeaderButtonType="TextButton" />
                                        <telerik:GridBoundColumn HeaderText="ComponentModel" DataField="ComponentModel" SortExpression="ComponentModel" UniqueName="ComponentModel"
                                            HeaderButtonType="TextButton" />
                                        <telerik:GridBoundColumn HeaderText="ComponentDesc" DataField="ComponentDesc" SortExpression="ComponentDesc" UniqueName="ComponentDesc"
                                            HeaderButtonType="TextButton" />
                                        <telerik:GridBoundColumn HeaderText="ComponentType" DataField="ComponentType" SortExpression="ComponentType" UniqueName="ComponentType"
                                            HeaderButtonType="TextButton" />
                                        <telerik:GridBoundColumn HeaderText="Last Condition" DataField="LastCondition" SortExpression="LastCondition" UniqueName="LastCondition"
                                            HeaderButtonType="TextButton" />
                                        <telerik:GridDateTimeColumn PickerType="DatePicker" DataFormatString="{0:d}" CurrentFilterFunction="EqualTo" UniqueName="LastSampleDate"
                                            ShowFilterIcon="false" AutoPostBackOnFilter="true" FilterDateFormat="MM/dd/yyyy"
                                            EnableRangeFiltering="false" HeaderText="Last Sample Date" DataField="LastSampleDate"
                                            SortExpression="LastSampleDate" HeaderButtonType="TextButton" />
                                    </Columns>
                                </telerik:GridTableView>
                            </DetailTables>
                            <Columns>
                                <telerik:GridBoundColumn HeaderText="TypeId" DataField="TypeId" SortExpression="TypeId"
                                    HeaderButtonType="TextButton" Display="false" />
                                <telerik:GridBoundColumn HeaderText="AccountId" DataField="AccountId" SortExpression="AccountId"
                                    Display="false" HeaderButtonType="TextButton" />
                                <telerik:GridBoundColumn HeaderText="Id" DataField="Id" SortExpression="Id" HeaderButtonType="TextButton"
                                    Display="false" />
                                <telerik:GridBoundColumn FilterControlWidth="70px" HeaderText="Account Name" DataField="LastName"  UniqueName ="LastName"
                                    CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true" SortExpression="LastName"
                                    HeaderButtonType="TextButton" />
                                <telerik:GridBoundColumn FilterControlWidth="70px" HeaderText="City" DataField="City"
                                    CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true" SortExpression="City"
                                    HeaderButtonType="TextButton" />
                                <telerik:GridBoundColumn FilterControlWidth="70px" HeaderText="State" DataField="State"
                                    CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true" SortExpression="State"
                                    HeaderButtonType="TextButton" />
                                <telerik:GridBoundColumn FilterControlWidth="100px" HeaderText="Country" DataField="Country"
                                    CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true" SortExpression="Country"
                                    HeaderButtonType="TextButton" />
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>


    .CS File
    ----------------------------------------
      protected void RdGridDeleteSample_ItemCreated(object sender, GridItemEventArgs e)
            {

                if (e.Item is GridHeaderItem)
                {
                    GridHeaderItem header = (GridHeaderItem)e.Item;
                    RdGridDeleteSample.MasterTableView.GetColumn("LastName").HeaderText = GetMyLanguage("AccountName");
                    RdGridDeleteSample.MasterTableView.GetColumn("City").HeaderText = GetMyLanguage("City");
                    RdGridDeleteSample.MasterTableView.GetColumn("State").HeaderText = GetMyLanguage("State");
                    RdGridDeleteSample.MasterTableView.GetColumn("Country").HeaderText = GetMyLanguage("Country");

                    //header["LastName"].Text = GetMyLanguage("AccountName");
                    //header["City"].Text = GetMyLanguage("City");
                    //header["State"].Text = GetMyLanguage("State");
                    //header["Country"].Text = GetMyLanguage("Country");

                    RdGridDeleteSample.MasterTableView.DetailTables[0].GetColumn("CustUnitId").HeaderText = "CustUnitId";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].GetColumn("UnitMake").HeaderText = "UnitMake";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].GetColumn("UnitMakeModel").HeaderText = "UnitModel";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].GetColumn("ComponentModel").HeaderText = "ComponentModel";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].GetColumn("ComponentDesc").HeaderText = "ComponentDesc";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].GetColumn("ComponentType").HeaderText = "ComponentType";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].GetColumn("LastCondition").HeaderText = "LastCondition";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].GetColumn("LastSampleDate").HeaderText = "LastSampleDate";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].GetColumn("LastSampleDate").HeaderText = "LastSampleDate";

                    RdGridDeleteSample.MasterTableView.DetailTables[0].DetailTables[0].GetColumn("Delete").HeaderText = "Delete";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].DetailTables[0].GetColumn("LastSample").HeaderText = "LastSample";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].DetailTables[0].GetColumn("AnalysisMode").HeaderText = "AnalysisMode";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].DetailTables[0].GetColumn("SampleCondition").HeaderText = "SampleCondition";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].DetailTables[0].GetColumn("LastSampleDate").HeaderText = "LastSampleDate";
                    RdGridDeleteSample.MasterTableView.DetailTables[0].DetailTables[0].GetColumn("PostedDate").HeaderText = "PostedDate";

                    //header["CustUnitId"].Text = GetMyLanguage("CustUnitId");
                    //header["UnitMake"].Text = GetMyLanguage("UnitMake");
                    //header["UnitModel"].Text = GetMyLanguage("UnitModel");
                    //header["ComponentModel"].Text = GetMyLanguage("ComponentModel");
                    //header["ComponentDesc"].Text = GetMyLanguage("ComponentDesc");
                    //header["ComponentType"].Text = GetMyLanguage("ComponentType");
                    //header["LastCondition"].Text = GetMyLanguage("LastCondition");
                    //header["LastSampleDate"].Text = GetMyLanguage("LastSampleDate");
                    //header["Delete"].Text = GetMyLanguage("Delete");
                    //header["LastSample"].Text = GetMyLanguage("LastSample");

                    //header["AnalysisMode"].Text = GetMyLanguage("AnalysisMode");
                    //header["SampleCondition"].Text = GetMyLanguage("SampleCondition");
                    //header["LastSampleDate"].Text = GetMyLanguage("LastSampleDate");
                    //header["PostedDate"].Text = GetMyLanguage("PostedDate");
                }


            }


    Thanks Advance
  9. Angel Petrov
    Admin
    Angel Petrov avatar
    1007 posts

    Posted 04 Sep 2014 Link to this post

    Hi,

    Changing the header text in the OnItemCreated event will not work as it is fired too early for that purpose. Please try moving the logic in the OnItemDataBound or OnPreRender events and test whether this resolves the problem.

    Regards,
    Angel Petrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017