RadGrid is refreshing after RadWindow opened.

2 posts, 0 answers
  1. Ruchi
    Ruchi avatar
    54 posts
    Member since:
    Apr 2012

    Posted 24 Mar 2015 Link to this post

    Hello Team,

    I am working on one web applicaiton, where we are using radgrid with linkbutton inside template column.

    On click of link button we are opening radwindow with a radgrid inside.

    On click of link button radwindow opens perfect with rebinding grid inside.

    The issue is on click of linkbutton it refresh the grid before opening radwindow.

    Can anyone help me out with this?

    Thanks in Advance,
    Ruchi Patel

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DemoPage.aspx.cs" Inherits="DemoApp.DemoPage" %>
     
    <!DOCTYPE html>
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
                <telerik:RadScriptBlock ID="scrCode_Outlier" runat="server">
                    <script type="text/javascript">
                        function OpenRadWin(ID) {
                            debugger
                            <%--document.getElementById("<%=hdnValue.ClientID %>").setAttribute('value', ID);--%>
                            var wnd = $find("<%=rdRTOutlierWindow.ClientID %>");
                            wnd.show();
                        }
                    </script>
                </telerik:RadScriptBlock>
                <telerik:RadAjaxManager ID="radmgr" runat="server">
                    <AjaxSettings>
                        <telerik:AjaxSetting AjaxControlID="rgRTOutlierView">
                            <UpdatedControls>
                                <telerik:AjaxUpdatedControl ControlID="rgRTOutlierView"></telerik:AjaxUpdatedControl>
                            </UpdatedControls>
                        </telerik:AjaxSetting>
                    </AjaxSettings>
                </telerik:RadAjaxManager>
                <telerik:RadWindow ID="rdRTOutlierWindow" runat="server" Modal="true" ReloadOnShow="true" MinWidth="1000px" MinHeight="400px" EnableViewState="true">
                    <ContentTemplate>
                        <telerik:RadAjaxPanel ID="rdpnl_RTDetail" runat="server">
                            <telerik:RadGrid ID="rgRTOutlierDetail" runat="server" AllowPaging="True" AllowSorting="true" AutoGenerateColumns="true" ClientSettings-EnablePostBackOnRowClick="false" OnNeedDataSource="rgRTOutlierDetail_NeedDataSource"
                                ExportSettings-IgnorePaging="true" ExportSettings-ExportOnlyData="true" ExportSettings-Excel-Format="Biff" MasterTableView-CommandItemSettings-ShowExportToExcelButton="true" MasterTableView-CommandItemSettings-ShowExportToCsvButton="true" MasterTableView-CommandItemSettings-ShowExportToPdfButton="true">
                                <MasterTableView DataKeyNames="ID">
                                    <CommandItemSettings ShowAddNewRecordButton="false" />
                                    <Columns></Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
                        </telerik:RadAjaxPanel>
                    </ContentTemplate>
                </telerik:RadWindow>
     
                <telerik:RadAjaxPanel ID="rdpnl_RT" runat="server" LoadingPanelID="LoadingPanel1" Width="700px" Height="300px">
     
                    <telerik:RadGrid ID="rgRTOutlierView" runat="server" AllowPaging="True" AllowSorting="true" AutoGenerateColumns="false" Width="100%"
                        OnNeedDataSource="rgRTOutlierView_NeedDataSource" OnItemCommand="rgRTOutlierView_ItemCommand"
                        PageSize="2" EnablePostBackOnRowClick="true" MasterTableView-CommandItemDisplay="Bottom">
                        <MasterTableView CommandItemDisplay="Bottom" DataKeyNames="ID">
                            <CommandItemSettings ShowAddNewRecordButton="false" />
                            <Columns>
                                <telerik:GridTemplateColumn AllowFiltering="false" HeaderText="Detail" DataField="ID" UniqueName="ID" HeaderStyle-Width="10%">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="hylnkAccn" runat="server" CommandName="Detail" CommandArgument='<%# Eval("ID") %>' Text="Detail" OnClientClick='<%# "OpenRadWin(" + Eval("ID") + ");" %>'></asp:LinkButton><%--OnClientClick='<%# "OpenRadWin(" + Eval("ID") + ");" %>'--%>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn DataField="ID" HeaderText="ID" HeaderStyle-Width="10%"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="UserName" HeaderText="UserName" HeaderStyle-Width="20%"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Education" HeaderText="Education" HeaderStyle-Width="20%"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Education" HeaderText="Education" HeaderStyle-Width="30%"></telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                        <ClientSettings>
                            <Selecting AllowRowSelect="True" />
                            <ClientEvents OnCommand="RadGridCommand" />
                            <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                        </ClientSettings>
                    </telerik:RadGrid>
                    <telerik:RadCodeBlock runat="server" ID="radcode1">
                        <script type="text/javascript">
                            function RadGridCommand(sender, args) {
                                debugger
                                if (args.get_commandName() == "Detail") {
                                    var itemIndex = args.get_commandArgument();
                                    var rowID = (itemIndex != null && itemIndex != undefined && itemIndex != "") ? args.get_tableView()._dataSource[itemIndex].ID : 0;
                                    OpenRadWin(rowID);
                                }
                                args.set_cancel(true);
                            }
     
                        </script>
                    </telerik:RadCodeBlock>
                </telerik:RadAjaxPanel>
            </div>
        </form>
    </body>
    </html>
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
     
    namespace DemoApp
    {
        public partial class DemoPage : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    rgRTOutlierView.DataBind();
                }
            }
     
            protected void rgRTOutlierView_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
            {
                //(sender as RadGrid).DataSource = GetDataTable();
     
                rgRTOutlierView.DataSource = GetDataTable();
     
            }
            protected void rgRTOutlierView_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
            {
                if (e.CommandName.ToLower().Equals("detail"))
                {
                    rgRTOutlierDetail.Rebind();
                }
            }
            public DataTable GetDataTable()
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("Id", typeof(string));
                dt.Columns.Add("UserName", typeof(string));
                dt.Columns.Add("Education", typeof(string));
                dt.Columns.Add("Location", typeof(string));
     
                DataRow dtrow = dt.NewRow();   
                dtrow["Id"] = 1;           
                dtrow["UserName"] = "SureshDasari";
                dtrow["Education"] = "B.Tech";
                dtrow["Location"] = "Chennai";
                dt.Rows.Add(dtrow);
     
                dtrow = dt.NewRow();       
                dtrow["Id"] = 2;           
                dtrow["UserName"] = "MadhavSai";
                dtrow["Education"] = "MBA";
                dtrow["Location"] = "Nagpur";
                dt.Rows.Add(dtrow);
     
                dtrow = dt.NewRow();       
                dtrow["Id"] = 3;           
                dtrow["UserName"] = "MaheshDasari";
                dtrow["Education"] = "B.Tech";
                dtrow["Location"] = "Nuzividu";
                dt.Rows.Add(dtrow);
     
                dtrow = dt.NewRow();       
                dtrow["Id"] = 4;           
                dtrow["UserName"] = "Mahendra";
                dtrow["Education"] = "CA";
                dtrow["Location"] = "Guntur";
                dt.Rows.Add(dtrow);
     
                return dt;
            }
     
            protected void rgRTOutlierDetail_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
            {
                rgRTOutlierDetail.DataSource = GetDataTable();
            }
     
        }
    }

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 26 Mar 2015 Link to this post

    Hi Ruchi,

    You should prevent the postback from the link button clicks by adding a return false; statement to the onclick handler that gets rendered.

    Regards,

    Marin Bratanov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

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