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

expand image icon of other child grid get changed on collapse click

2 Answers 42 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Shubham
Top achievements
Rank 1
Shubham asked on 07 Jan 2014, 10:51 AM
Hi All,
          I have two detail tables in my Rad grid which renders three child grids on UI  with expand and collapse button. Now When collapse the last child grid then upper two child grid's collapse button image changes in to expand button image . I had set  HierarchyLoadMode="ServerOnDemand"  in <masterTableview>  . If set this to "Client " it works fine but the grid does not get refreshed after deleting record from the grid . Please  Let me know what am  i doing wrong 


   <telerik:RadGrid ID="RadGrid" OnPreRender="RadGrid_PreRender" OnNeedDataSource="RadGrid_NeedDataSource" OnItemCommand="RadGrid_ItemCommand1"
                                    runat="server" Width="99.4%" OnDetailTableDataBind="RadGrid_DetailTableDataBind"
                                    OnItemDataBound="RadGrid_ItemDataBound" OnItemCreated="RadGrid_ItemCreated"
                                    OnPageIndexChanged="RadGrid_PageIndexChanged" >
                                    <ClientSettings>
                                        <Resizing AllowColumnResize="true" EnableRealTimeResize="true" ResizeGridOnColumnResize="true"
                                            ClipCellContentOnResize="true" />
                                    </ClientSettings>
                                    <MasterTableView  HierarchyLoadMode="ServerOnDemand"
                                        HierarchyDefaultExpanded="false" TableLayout="Fixed" CommandItemDisplay="Top">
                                           <Columns>
                                            <telerik:GridBoundColumn SortExpression="Name" HeaderText="Text1" HeaderButtonType="TextButton"
                                                DataField="VendorName">
                                                <%-- Defect# 12711--%>
                                            </telerik:GridBoundColumn>
                                        </Columns>
                                        <DetailTables>
                                            <telerik:GridTableView DataKeyNames="KeyName" GridLines="None" HierarchyLoadMode="Client" HierarchyDefaultExpanded="true">
                                                <PagerStyle Visible="false" />
                                                <ParentTableRelation>
                                                    <telerik:GridRelationFields  MasterKeyField="Name" />
                                                </ParentTableRelation>
                                                <Columns>
                                                    <telerik:GridBoundColumn  HeaderText="text"
                                                        UniqueName="FuelImportConfigurationDesc">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="Name2" HeaderText="Name2" UniqueName="FuelVendor">
                                                        <%-- Defect# 12711--%>
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="FixedColumn" HeaderText="Fixed Column" UniqueName="FixedColumn">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="Delimiter" HeaderText="Delimiter" UniqueName="Delimiter">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="Name3" HeaderText="Name3"
                                                        UniqueName="DisbursementType">
                                                    </telerik:GridBoundColumn>
                                                </Columns>
                                                <DetailTables>
                                                    <telerik:GridTableView DataKeyNames="Name4" Width="100%" GridLines="None"
                                                        HierarchyLoadMode="Client" AllowCustomPaging="true">
                                                        <ParentTableRelation>
                                                            <telerik:GridRelationFields DetailKeyField="Name5" MasterKeyField="Name5" />
                                                        </ParentTableRelation>
                                                        <Columns>
                                                            <telerik:GridTemplateColumn UniqueName="SelectItemCheckBoxColumn" Resizable="false" Reorderable="false">
                                                                <ItemTemplate>
                                                                    <asp:CheckBox ID="SelectItemCheckBox" runat="server" onclick="return CheckItem(this);" />
                                                                </ItemTemplate>
                                                                <HeaderTemplate>
                                                                    <asp:CheckBox ID="SelectHeaderCheckBox" runat="server" onclick="CheckAll(this);" />
                                                                </HeaderTemplate>
                                                            </telerik:GridTemplateColumn>
                                                            <telerik:GridTemplateColumn HeaderText="Action" UniqueName="TemplateColumn" Resizable="false" Reorderable="false">
                                                                <ItemTemplate>
                                                                    <asp:HyperLink ID="EditHyperLink" runat="server" Text="Edit" SkinID="SmallHyperLink"></asp:HyperLink>
                                                                </ItemTemplate>
                                                                <HeaderStyle Width="5%" />
                                                            </telerik:GridTemplateColumn>
                                                            <telerik:GridBoundColumn DataField="Name6" HeaderText="Name5"
                                                                UniqueName="Name6" SortExpression="Name6">
                                                                <HeaderStyle Width="10%" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="Name7" HeaderText="Asset Number" UniqueName="Name7"
                                                                SortExpression="Name7">
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="Name8" HeaderText="Name8" UniqueName="Name8"
                                                                SortExpression="Name8">
                                                                <HeaderStyle Width="10%" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="Name9" HeaderText="Name9" UniqueName="Name9"
                                                                SortExpression="Name9">
                                                                <HeaderStyle Width="10%" />
                                                            </telerik:GridBoundColumn>
                                                           <telerik:GridBoundColumn DataField="ErrorDescription" HeaderText="Error Description"
                                                                UniqueName="ErrorDescription" SortExpression="ErrorDescription">
                                                                <HeaderStyle Width="20%" />
                                                            </telerik:GridBoundColumn>
                                                        </Columns>
                                                    </telerik:GridTableView>
                                                </DetailTables>
                                            </telerik:GridTableView>
                                        </DetailTables>
                                    </MasterTableView>
                                </telerik:RadGrid>



here is the code behind
   protected void Page_Init(object sender, EventArgs e)
    {
       
    } 
    protected void RadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
       
    }

    protected void RadGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
    {
       
    }

    protected void RadGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
       
    }
    protected void RadGrid_PreRender(object sender, EventArgs e)
    {
        Boolean hasRecords = false;
        if (RadGrid.MasterTableView.Items.Count > 0)
        {
            foreach (GridDataItem dataItem in RadGrid.MasterTableView.Items)
            {

                foreach (GridDataItem nestedDataItem in dataItem.ChildItem.NestedTableViews[0].Items)
                {

                    if (!hasRecords && nestedDataItem.ChildItem.NestedTableViews[0].Items.Count > 0)
                    {
                        hasRecords = true;
                        break;
                    }
                }
                if (hasRecords)
                    break;

            }
        }

        ClearSelectedLinkButton.Enabled = hasRecords;
    }    
    
    protected void Page_PreRender(object sender, System.EventArgs e)
    {
        GridItem commandItem = RadGrid.MasterTableView.GetItems(GridItemType.CommandItem)[0];
        ImageButton exportToExcelImageButton = commandItem.FindControl("ExportToExcelImageButton") as ImageButton;
        Boolean isGridHasData = RadGrid.Items.Count > 0;
        if (exportToExcelImageButton != null)
        {
            exportToExcelImageButton.Enabled = isGridHasData;
            if (exportToExcelImageButton.Enabled)
            {
                exportToExcelImageButton.Attributes.Add("onclick", String.Format("DisableAjax(\"{0}\", \"\"); return false;", exportToExcelImageButton.UniqueID));
                exportToExcelImageButton.Style.Add(StringResources.CssCursorKey, StringResources.CssCursorValue);
            }
        }
    }
   

    protected void RadGrid_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            if (objFasterCache[String.Format("Vendor{0}", _guid)] != null)
            {
                if (Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Name1"]) == (Int32)objFasterCache[String.Format("Name{0}", _guid)])
                    e.Item.OwnerTableView.HierarchyDefaultExpanded = true;
                else
                    e.Item.OwnerTableView.HierarchyDefaultExpanded = false;
            }
        }
    }

Thanks

  

2 Answers, 1 is accepted

Sort by
0
Venelin
Telerik team
answered on 10 Jan 2014, 08:48 AM
Hello Shubham,

Could you please confirm that this is the markup you really use. I doubt that this will work with these relations settings because as stated in out online documentation: "You must set the DataKeyNames property of every parent table view in the hierarchy to specify the fields in the table's data source that are used for linking to child tables." Also which version of the controls do you use? We are not familiar with such an issue.

It will be best if you open a regular support ticket and send us a project that successfully reproduces the problem so we can test and debug locally. With this current snipped the issue is not reproducing event I correct the table relations.

Regards,
Venelin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Shubham
Top achievements
Rank 1
answered on 21 Jan 2014, 10:38 AM
Hi Venelin

Thanx for the reply . I looked back in  to  the issue  and found  out the reason and  it  is  working  now .

Shubham
Tags
Ajax
Asked by
Shubham
Top achievements
Rank 1
Answers by
Venelin
Telerik team
Shubham
Top achievements
Rank 1
Share this question
or