Radwindow inside GridTemplateColumn

13 posts, 1 answers
  1. Loyal User
    Loyal User avatar
    37 posts
    Member since:
    Apr 2012

    Posted 13 Feb 2014 Link to this post

    OpenArchiveWindowI have a radgrid with GridTemplateColumn that contain linkbutton :
    <telerik:GridTemplateColumn HeaderText='<%$Resources:Resources,Archive %>'>
       <ItemTemplate>
          <asp:LinkButton runat="server" ID="getArchiveLB" OnClick="getArchiveLB_Click" CommandArgument='<%# Eval("CONFIGURATION_KEY") %>' OnClientClick="OpenArchiveWindow();">Archive
          </asp:LinkButton>
       </ItemTemplate>
    </telerik:GridTemplateColumn>

    OpenArchiveWindow() : js fct to open a radwindow :
    <telerik:RadWindow runat="server" ID="ArchiveWindow" ShowContentDuringLoad="false" EnableViewState="false"
        Modal="true">
        <ContentTemplate>
            <telerik:RadGrid runat="server" ID="ConfigurationArchiveGrid" AutoGenerateColumns="true"></telerik:RadGrid>
        </ContentTemplate>
    </telerik:RadWindow>

    and getArchiveLB_Click() is server side fonction to databind grid ('ConfigurationArchiveGrid') inside the radwindow ('ArchiveWindow'),

    inside getArchiveLB_Click: radgrid is binded , but doesn't appears inside radwindow ,

    how can i achieve that ?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Feb 2014 in reply to Loyal User Link to this post

    Hi,

    Please have a look at the sample code snippet.

    ASPX:
    <telerik:GridTemplateColumn >
        <ItemTemplate>
            <asp:LinkButton runat="server" ID="getArchiveLB" OnClick="getArchiveLB_Click" OnClientClick="return OpenArchiveWindow();"> Archive
            </asp:LinkButton>
        </ItemTemplate>
    </telerik:GridTemplateColumn>
    . . . .
    <telerik:RadWindow runat="server" ID="ArchiveWindow">
        <ContentTemplate>
            <telerik:RadGrid runat="server" ID="ConfigurationArchiveGrid" OnNeedDataSource="ConfigurationArchiveGrid_NeedDataSource">
            </telerik:RadGrid>
        </ContentTemplate>
    </telerik:RadWindow>

    JS:
    <script type="text/javascript">
     function OpenArchiveWindow() {      
       var win = $find("<%=ArchiveWindow.ClientID %>");
       win.show();
       return false;
     }
     </script>

    C#:
    protected void getArchiveLB_Click(object sender, EventArgs e)
    {
      ConfigurationArchiveGrid.Rebind();
    }
    protected void ConfigurationArchiveGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
       //Code to bind  ConfigurationArchiveGrid
    }

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Loyal User
    Loyal User avatar
    37 posts
    Member since:
    Apr 2012

    Posted 13 Feb 2014 in reply to Princy Link to this post

    thanks a lot,
    i tried it.. it works correctly if i don't use command argument in linkbutton.
    In my case, DataSource of radgrid is based on commandArgument passed by linkbutton.
  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 13 Feb 2014 in reply to Loyal User Link to this post

    Hello,

    I have modified the  Princy's code.

    public string CommandArgument
        {
            get
            {
                string text = (string)ViewState["CommandArgument"];
                if (text != null)
                    return text;
                else
                    return string.Empty;
            }
            set
            {
                ViewState["CommandArgument"] = value;
            }
        }
     
        protected void getArchiveLB_Click(object sender, EventArgs e)
        {
            CommandArgument = (sender as LinkButton).CommandArgument;
            ConfigurationArchiveGrid.Rebind();
        }
        protected void ConfigurationArchiveGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            //Code to bind  ConfigurationArchiveGrid
            //Use CommandArgument Here
        }


    Thanks,
    Jayesh Goyani
  6. Loyal User
    Loyal User avatar
    37 posts
    Member since:
    Apr 2012

    Posted 13 Feb 2014 in reply to Jayesh Goyani Link to this post

    thanks Jayesh Goyani ..

    based on your code , i can get datasource correctly,
    but radwindow still empty after rebind radgrid ..
  7. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 13 Feb 2014 in reply to Loyal User Link to this post

    Hello,

    As per my knowledge this issue is raised because of inside onclick funciton "OpenArchiveWindow()" you have written "return false".
    If you written "return false" then it will not fire the server side click event.

    Thanks,
    Jayesh Goyani
  8. Loyal User
    Loyal User avatar
    37 posts
    Member since:
    Apr 2012

    Posted 13 Feb 2014 in reply to Jayesh Goyani Link to this post

    my code doesn't return false,

    return false inside js fct prevent event in server side to be fired.
  9. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 13 Feb 2014 in reply to Loyal User Link to this post

    Hello,

    Is your radgrid ajaxify?

    If possible then please your code.

    Thanks,
    Jayesh Goyani
  10. Loyal User
    Loyal User avatar
    37 posts
    Member since:
    Apr 2012

    Posted 13 Feb 2014 in reply to Jayesh Goyani Link to this post

    this is the radgrid :

    <asp:UpdatePanel runat="server" ID="up1">
            <ContentTemplate>
                <telerik:RadGrid runat="server" ID="ConfigurationDataGrid" OnNeedDataSource="ConfigurationDataGrid_NeedDataSource" AutoGenerateColumns="false" OnItemDataBound="ConfigurationDataGrid_ItemDataBound" OnItemCommand="ConfigurationDataGrid_ItemCommand">
                    <MasterTableView EditMode="InPlace">
                        <Columns>
                    .....
                            <telerik:GridTemplateColumn HeaderText='<%$Resources:Resources,Archive %>'>
                                <ItemTemplate>
                                    <asp:LinkButton runat="server" ID="getArchiveLB" OnClick="getArchiveLB_Click" CommandArgument='<%# Eval("CONFIGURATION_KEY") %>' OnClientClick="return OpenArchiveWindow();">Archive</asp:LinkButton>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
     
                    </MasterTableView>
                </telerik:RadGrid>
     
            </ContentTemplate>
        </asp:UpdatePanel>
  11. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 13 Feb 2014 in reply to Loyal User Link to this post

    Hello,

    public string CommandArgument
        {
            get
            {
                string text = (string)ViewState["CommandArgument"];
                if (text != null)
                    return text;
                else
                    return string.Empty;
            }
            set
            {
                ViewState["CommandArgument"] = value;
            }
        }
     
        protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            List<Employee> list = new List<Employee>(); ;
     
            Employee obj = new Employee();
            obj.ID = "1";
            obj.Name = "Name1";
            list.Add(obj);
     
            obj = new Employee();
            obj.ID = "2";
            obj.Name = "Name2";
            list.Add(obj);
     
            RadGrid1.DataSource = list;
        }
     
        protected void getArchiveLB_Click(object sender, EventArgs e)
        {
            ArchiveWindow.VisibleOnPageLoad = true;
            CommandArgument = (sender as LinkButton).CommandArgument;
            ConfigurationArchiveGrid.Visible = true;
            ConfigurationArchiveGrid.Rebind();
        }
     
        protected void ConfigurationArchiveGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            List<Employee> list = new List<Employee>(); ;
     
            Employee obj = new Employee();
            obj.ID = "1";
            obj.Name = "Nassssme1__" + CommandArgument;
            list.Add(obj);
     
            obj = new Employee();
            obj.ID = "2";
            obj.Name = "Nasssssme2";
            list.Add(obj);
     
            ConfigurationArchiveGrid.DataSource = list;
        }
     
     
    .........
    .........
    [Serializable]
    public class Employee
    {
        public string ID { get; set; }
        public string Name { get; set; }
        public bool IsActive { get; set; }
    }
    <head runat="server">
        <title></title>
        <script src="Script/jquery-1.10.2.min.js"></script>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script>
                function OpenArchiveWindow() {
                    var win = $find("<%=ArchiveWindow.ClientID %>");
                   // win.show();
                }
            </script>
     
        </telerik:RadCodeBlock>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <telerik:RadScriptManager ID="RadScriptManager1" EnablePageMethods="true" runat="server">
                </telerik:RadScriptManager>
                <asp:UpdatePanel runat="server" ID="up1">
                    <ContentTemplate>
                        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
                            AllowFilteringByColumn="true" AllowPaging="true">
                            <PagerStyle AlwaysVisible="true" />
                            <MasterTableView DataKeyNames="ID">
                                <Columns>
                                    <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
                                    <telerik:GridTemplateColumn>
                                        <ItemTemplate>
                                            <asp:LinkButton runat="server" ID="getArchiveLB" CommandArgument='<%# Eval("ID") %>' OnClick="getArchiveLB_Click" OnClientClick="return OpenArchiveWindow();"> Archive
                                            </asp:LinkButton>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>
                                <Selecting AllowRowSelect="true" />
                            </ClientSettings>
                        </telerik:RadGrid>
                        <telerik:RadWindow runat="server" ID="ArchiveWindow">
                            <ContentTemplate>
                                <telerik:RadGrid runat="server" ID="ConfigurationArchiveGrid" OnNeedDataSource="ConfigurationArchiveGrid_NeedDataSource" Visible="false">
                                </telerik:RadGrid>
                            </ContentTemplate>
                        </telerik:RadWindow>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </form>
    </body>
    </html>

    Also try with the below code
    <script>
              function OpenArchiveWindow() {
                  var win = $find("<%=ArchiveWindow.ClientID %>");
                  win.show();
              }
          </script>


    Thanks,
    Jayesh Goyani
  12. Loyal User
    Loyal User avatar
    37 posts
    Member since:
    Apr 2012

    Posted 13 Feb 2014 in reply to Jayesh Goyani Link to this post

    thanks a lot Jayesh Goyani ..

    it works correctly but inside ConfigurationArchiveGrid_NeedDataSource () i reset command Argument to emptyString .
  13. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 13 Feb 2014 Link to this post

    Hello,

    Let me know if any concern.

    Thanks,
    Jayesh Goyani
  14. Asutosh
    Asutosh avatar
    130 posts
    Member since:
    Sep 2013

    Posted 17 Jul 2014 in reply to Jayesh Goyani Link to this post

    hi
    i am using radwindow in that i have radgrid
    now issue is that when i try to scroll my grid using mouse scroller my whole page scroll which is behing from radwindow and also my radwindow also scroll
    i want to make my radgrid scroll on mouse scroller when my radwindow is open 
    how can i achieve that?
    i have attached sample image also for that 
    thanks
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017