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

Check Box OnCheckedChanged - RadAjaxLoadingPanel1

3 Answers 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mehmet
Top achievements
Rank 1
Mehmet asked on 24 Jul 2014, 01:50 AM
Hi there,

I have added a checkbox on my page which expands & collapses the inner grids. However, I cannot use the Ajax Loading Panel with its on checked changed server-side event.
What is it wrong here ?
ASPX:
01.        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
02.        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
03.            <AjaxSettings>
04.                <telerik:AjaxSetting AjaxControlID="RadGrid1">
05.                    <UpdatedControls>
06.                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
07.                    </UpdatedControls>
08.                </telerik:AjaxSetting>
09.                <telerik:AjaxSetting AjaxControlID="RadGrid2">
10.                    <UpdatedControls>
11.                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
12.                    </UpdatedControls>
13.                </telerik:AjaxSetting>
14.                <telerik:AjaxSetting AjaxControlID="chkSalesReportExpandAll">
15.                    <UpdatedControls>
16.                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
17.                    </UpdatedControls>
18.                </telerik:AjaxSetting>
19.            </AjaxSettings>
20.            <%--<ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd" />--%>
21.        </telerik:RadAjaxManager>
22.        <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" Skin="Default" />
23.        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
24.            <script type="text/javascript">
25.                var hdfSelectedTab = $('#<%=hdfSelectedTab.ClientID%>');
26.            </script>
27.        </telerik:RadCodeBlock>
28. 
29.                    <asp:CheckBox ID="chkSalesReportExpandAll" AutoPostBack="true" Text="Expand All"
30.                        OnCheckedChanged="chkSalesReportExpandAll_CheckedChanged" runat="server" Visible="false"></asp:CheckBox>
31.                </div>
32.                <br />
33.                <div id="pnlSalesReport" runat="server" visible="false">
34.                    <asp:ImageButton ID="salesReportHTML" runat="server" OnClick="salesReportHTML_Click" AlternateText="Html" ImageUrl="images/file-extension-xls-html-icon.png"
35.                        CssClass="pdfButton"></asp:ImageButton>
36.                    <asp:ImageButton ID="salesReportExcelML" runat="server" OnClick="salesReportHTML_Click" AlternateText="ExcelML" ImageUrl="images/file-extension-xls-icon.png"
37.                        CssClass="pdfButton"></asp:ImageButton>
38.                    <asp:ImageButton ID="salesReportBiff" runat="server" OnClick="salesReportHTML_Click" AlternateText="Biff" ImageUrl="images/file-extension-xls-biff-icon.png"
39.                        CssClass="pdfButton"></asp:ImageButton>
40.                    <asp:ImageButton ID="salesReportPDF" runat="server" OnClick="salesReportPDF_Click" ImageUrl="images/file-extension-pdf-icon.png"
41.                        CssClass="pdfButton"></asp:ImageButton>
42.                    <br />
43.                    <telerik:RadGrid AutoGenerateColumns="False" ID="RadGrid2" EnableViewState="true" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" runat="server" ShowFooter="true"
44.                        OnItemCommand="RadGrid2_ItemCommand" OnItemCreated="RadGrid2_ItemCreated" EnableLinqExpressions="true" HtmlEncode="true" PageSize="50" Height="100%" OnNeedDataSource="RadGrid2_NeedDataSource"
45.                        ShowGroupPanel="True" CellSpacing="-1" GridLines="Both" Skin="Office2010Silver" Width="100%">
46.                        <PagerStyle Mode="NextPrevAndNumeric" />
47.                        <GroupingSettings CaseSensitive="false" />
48.                        <ClientSettings AllowKeyboardNavigation="true">
49.                        </ClientSettings>
50.                        <ExportSettings IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true">
51.                            <Pdf PageHeight="210mm" PageWidth="297mm" DefaultFontFamily="Arial Unicode MS" PageTopMargin="45mm"
52.                                BorderStyle="Medium" BorderColor="#666666" PaperSize="A4">
53.                            </Pdf>
54.                        </ExportSettings>
55.........
56.........

Thank you

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 24 Jul 2014, 04:46 AM
Hi Mehmet,

I was not able to replicate such an issue at my end. Please try the following sample code snippet.

ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="grdSample">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="grdSample" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="chkExpandAll">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="grdSample"></telerik:AjaxUpdatedControl>
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" Skin="Default" />
<asp:CheckBox ID="chkExpandAll" AutoPostBack="true" Text="Expand All" OnCheckedChanged="chkExpandAll_CheckedChanged" runat="server" Visible="true"></asp:CheckBox>
<br />
<telerik:RadGrid ID="grdSample" runat="server" AutoGenerateColumns="False" AllowFilteringByColumn="true" Skin="Office2010Silver" AllowSorting="true" OnDetailTableDataBind="grdSample_DetailTableDataBind" OnNeedDataSource="grdSample_NeedDataSource">
    <PagerStyle Mode="NextPrevAndNumeric" />
    <GroupingSettings CaseSensitive="false" />
    <MasterTableView DataKeyNames="CountryID" HierarchyLoadMode="Client" Name="Country">
        <DetailTables>
            <telerik:GridTableView DataKeyNames="StateID" Name="State" HierarchyLoadMode="Client">
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="StateID" Name="District">
                        <Columns>
                            <telerik:GridBoundColumn HeaderText="DistrictID" DataField="DistrictID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="DistrictName" DataField="DistrictName">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                    <telerik:GridBoundColumn HeaderText="StateID" DataField="StateID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="StateName" DataField="StateName">
                    </telerik:GridBoundColumn>
                </Columns>
            </telerik:GridTableView>
        </DetailTables>
        <Columns>
            <telerik:GridBoundColumn  HeaderText="CountryID" DataField="CountryID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn  HeaderText="CountryName" DataField="CountryName">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void chkExpandAll_CheckedChanged(object sender, EventArgs e)
{
    grdSample.MasterTableView.HierarchyDefaultExpanded = true;
    grdSample.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;
    grdSample.Rebind();
}
protected void grdSample_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    if (!e.IsFromDetailTable)
    {
        grdSample.DataSource = GetDataTable("Select * from Country");
    }
}
 
protected void grdSample_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
    GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
    switch (e.DetailTableView.Name)
    {
        case "State":
            {
                string CountryID = dataItem.GetDataKeyValue("CountryID").ToString();
                e.DetailTableView.DataSource = GetDataTable("SELECT * FROM State WHERE CountryID = '" + CountryID + "'");
                break;
            }
        case "District":
            {
                string StateID = dataItem.GetDataKeyValue("StateID").ToString();
                e.DetailTableView.DataSource = GetDataTable("SELECT * FROM District WHERE StateID = '" + StateID + "'");
                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,
Shinu
0
Mehmet
Top achievements
Rank 1
answered on 24 Jul 2014, 05:15 AM
Hi Shinu,

Thanks for an answer.

my inner grid structure is below. Does it make difference?
01.<NestedViewTemplate>
02.                                <asp:Panel runat="server" ID="InnerContainer" CssClass="viewWrap" Visible="false">
03.                                    <telerik:RadGrid runat="server" ID="InvoiceDetail" ShowFooter="true" OnNeedDataSource="InvoiceDetail_NeedDataSource">
04.                                        <MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="true"
05.                                            DataKeyNames="InvoiceItemID" PageSize="7" HierarchyLoadMode="ServerOnDemand">
06.                                            <Columns>
07.                                                <telerik:GridBoundColumn HeaderText="Name" HeaderButtonType="TextButton"
08.                                                    DataField="InvoiceItemName" UniqueName="InvoiceItemName">
09.                                                </telerik:GridBoundColumn>
10.                                                <telerik:GridNumericColumn DataField="InvoiceItemUnitPrice" DataType="System.Decimal" NumericType="Currency"
11.                                                    HeaderText="InvoiceItemUnitPrice" SortExpression="InvoiceItemUnitPrice" UniqueName="InvoiceItemUnitPrice" Aggregate="Sum" FooterAggregateFormatString="{0:C}">
12.                                                    <FooterStyle Font-Bold="true"></FooterStyle>
13.                                                </telerik:GridNumericColumn>
14.                                                <telerik:GridBoundColumn DataField="InvoiceItemQuantity" HeaderText="InvoiceItemQuantity"
15.                                                    UniqueName="InvoiceItemQuantity">
16.                                                </telerik:GridBoundColumn>
17.                                                <telerik:GridNumericColumn DataField="InvoiceItemPrice" DataType="System.Decimal" NumericType="Currency"
18.                                                    HeaderText="InvoiceItemPrice" SortExpression="InvoiceItemPrice" UniqueName="InvoiceItemPrice" Aggregate="Sum" FooterAggregateFormatString="{0:C}">
19.                                                    <FooterStyle Font-Bold="true"></FooterStyle>
20.                                                </telerik:GridNumericColumn>
21.                                                <telerik:GridNumericColumn DataField="InvoiceItemGST" DataType="System.Decimal" NumericType="Currency"
22.                                                    HeaderText="InvoiceItemGST" SortExpression="InvoiceItemGST" UniqueName="InvoiceItemGST" Aggregate="Sum" FooterAggregateFormatString="{0:C}">
23.                                                    <FooterStyle Font-Bold="true"></FooterStyle>
24.                                                </telerik:GridNumericColumn>
25.                                                <telerik:GridNumericColumn DataField="InvoiceItemTotal" DataType="System.Decimal" NumericType="Currency"
26.                                                    HeaderText="InvoiceItemTotal" SortExpression="InvoiceItemTotal" UniqueName="InvoiceItemTotal" Aggregate="Sum" FooterAggregateFormatString="{0:C}">
27.                                                    <FooterStyle Font-Bold="true"></FooterStyle>
28.                                                </telerik:GridNumericColumn>
29.                                            </Columns>
30.                                        </MasterTableView>
31.                                    </telerik:RadGrid>
32. 
33.                                </asp:Panel>
34.                            </NestedViewTemplate>
0
Shinu
Top achievements
Rank 1
answered on 25 Jul 2014, 03:41 AM
Hi Mehmet,

Make sure you are binding the Grid properly. Please check the below code snippet:

C#:
void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExpandCollapseCommandName && !e.Item.Expanded)
    {
        GridDataItem parentItem = e.Item as GridDataItem;
        bind the grid on expand
        RadGrid rg = parentItem.ChildItem.FindControl("InvoiceDetail") as RadGrid;
        rg.Rebind();
    }
}
 
protected void chkSalesReportExpandAll_CheckedChanged(object sender, EventArgs e)
{
    RadGrid2.MasterTableView.HierarchyDefaultExpanded = true;    
    RadGrid2.Rebind();
}
protected void RadGrid2_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{      
        RadGrid2.DataSource = DataSource;       
}
 
protected void InvoiceDetail_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{     
    (sender as RadGrid).DataSource = DataSource
}

Thanks,
Shinu
Tags
Grid
Asked by
Mehmet
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Mehmet
Top achievements
Rank 1
Share this question
or