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

Radwindow inside GridTemplateColumn

12 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Loyal User
Top achievements
Rank 1
Loyal User asked on 13 Feb 2014, 08:06 AM
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 ?

12 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 13 Feb 2014, 09:37 AM
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
0
Loyal User
Top achievements
Rank 1
answered on 13 Feb 2014, 09:43 AM
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.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 13 Feb 2014, 09:59 AM
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
0
Loyal User
Top achievements
Rank 1
answered on 13 Feb 2014, 10:19 AM
thanks Jayesh Goyani ..

based on your code , i can get datasource correctly,
but radwindow still empty after rebind radgrid ..
0
Jayesh Goyani
Top achievements
Rank 2
answered on 13 Feb 2014, 11:02 AM
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
0
Loyal User
Top achievements
Rank 1
answered on 13 Feb 2014, 11:06 AM
my code doesn't return false,

return false inside js fct prevent event in server side to be fired.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 13 Feb 2014, 11:19 AM
Hello,

Is your radgrid ajaxify?

If possible then please your code.

Thanks,
Jayesh Goyani
0
Loyal User
Top achievements
Rank 1
answered on 13 Feb 2014, 11:22 AM
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>
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 13 Feb 2014, 11:34 AM
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
0
Loyal User
Top achievements
Rank 1
answered on 13 Feb 2014, 01:29 PM
thanks a lot Jayesh Goyani ..

it works correctly but inside ConfigurationArchiveGrid_NeedDataSource () i reset command Argument to emptyString .
0
Jayesh Goyani
Top achievements
Rank 2
answered on 13 Feb 2014, 04:26 PM
Hello,

Let me know if any concern.

Thanks,
Jayesh Goyani
0
Asutosh
Top achievements
Rank 1
answered on 17 Jul 2014, 11:07 AM
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
Tags
Grid
Asked by
Loyal User
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Loyal User
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Asutosh
Top achievements
Rank 1
Share this question
or