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

Radgrid inside a RadWindow

5 Answers 624 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
: Arumuga Vignesh
Top achievements
Rank 1
: Arumuga Vignesh asked on 30 Jul 2013, 05:13 PM
Hi,

I have requirement to display a radwindow with radgrid

Scenario:
On button click a dataset will be fetched from database, I have to display the dataset as a alert to the user in grid or someother telerik tool. Can you pls provide me a solution

Thanks  

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Jul 2013, 07:06 AM
Hi Arumuga,

Please have a look into the following code I tried which works fine at my end.

ASPX:
<telerik:RadButton ID="RadButton1" runat="server" Text="Display Data" OnClick="RadButton1_Click">
</telerik:RadButton>
<telerik:RadWindow ID="RadWindow1" runat="server" Width="300px" Height="300px" Title="Employee Details">
    <ContentTemplate>
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true">
        </telerik:RadGrid>
    </ContentTemplate>
</telerik:RadWindow>

C#:
protected void Page_Load(object sender, EventArgs e)
{
    RadWindow1.VisibleOnPageLoad = false;
}
protected void RadButton1_Click(object sender, EventArgs e)
{
    String connectionString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
    SqlConnection connection = new SqlConnection(connectionString);
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = new SqlCommand("SELECT FirstName, LastName FROM Employees", connection);
    DataSet dataset1 = new DataSet();
    connection.Open();
    try
    {
        adapter.Fill(dataset1);
        RadGrid1.DataSource = dataset1;
        RadGrid1.DataBind();
        RadWindow1.VisibleOnPageLoad = true;
    }
    finally
    {
        connection.Close();
    }
}

Thanks,
Shinu.
0
: Arumuga Vignesh
Top achievements
Rank 1
answered on 31 Jul 2013, 12:52 PM

Thanks Its working fine

But I have to add a OK button to close the window , it should be seperate from radgrid and it should not move when we scroll the radgrid

0
Shinu
Top achievements
Rank 2
answered on 01 Aug 2013, 06:30 AM
Hi Arumuga,

In order to perform RadGrid Scrolling you need to set the AllowScroll property of the RadGrid to true. By default its value is false. The ScrollHeight property specifies the height value beyond which the scrolling will be turned on. The default value is 300px. Please have a look into the updated ASPX which works as expected.

ASPX:
<telerik:RadButton ID="RadButton1" runat="server" Text="Display Data" OnClick="RadButton1_Click">
</telerik:RadButton>
<telerik:RadWindow ID="RadWindow1" runat="server" Width="400px" Height="370px" Title="Employee Details">
    <ContentTemplate>
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true">
            <ClientSettings>
                <Scrolling AllowScroll="true" ScrollHeight="230px" UseStaticHeaders="true" />
            </ClientSettings>
        </telerik:RadGrid>
        <br />
        <telerik:RadButton ID="RadButton2" runat="server" Text="OK" AutoPostBack="false"
            OnClientClicked="closeWindow">
        </telerik:RadButton>
    </ContentTemplate>
</telerik:RadWindow>

Thanks,
Shinu.
0
Umasankar
Top achievements
Rank 1
Veteran
answered on 01 Feb 2021, 12:26 PM

Hi ,

I have a requirement, where I have to open a rad window popup with grid from one rad window popup's Yes button click event.

First  I should a Radbutton , that will open a Yes or No popup, if I click yes  then I should show another radwindow popup with grid data. Could you please provide any suggestion on this ?

0
Doncho
Telerik team
answered on 04 Feb 2021, 09:34 AM

Hi Umasankar,

Here is a basic sample that seems to fit the described scenario:

<script>
    function OnClientClicked(sender, args) {
        var wn = $find('<%= RadWindow1.ClientID %>');
        wn.show();
    }
    function openGridWindow(sender, args) {
        var girdWindow = $find('<%= RadWindow2.ClientID %>');
        girdWindow.show();
    }

    function closeCurrentWindow(sender, args) {
        var wn = $find('<%= RadWindow1.ClientID %>');
        wn.close();
    }
</script>

<telerik:RadButton runat="server" ID="RadButton1" Text="Open dialog" AutoPostBack="false" OnClientClicked="OnClientClicked" />

<telerik:RadWindow ID="RadWindow1" runat="server">
    <ContentTemplate>
        Open RadGrid?
<telerik:RadButton runat="server" ID="RadButton2" Text="Yes" AutoPostBack="false" OnClientClicked="openGridWindow" />
        <telerik:RadButton runat="server" ID="RadButton3" Text="No" AutoPostBack="false" OnClientClicked="closeCurrentWindow" />

    </ContentTemplate>
</telerik:RadWindow>

<telerik:RadWindow ID="RadWindow2" runat="server" Width="400" Top="50">
    <ContentTemplate>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="300px" OnNeedDataSource="RadGrid1_NeedDataSource">
            <MasterTableView AutoGenerateColumns="True" DataKeyNames="ID">
            </MasterTableView>
        </telerik:RadGrid>
    </ContentTemplate>
</telerik:RadWindow>

C# code for binding the RadGrid

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    (sender as RadGrid).DataSource = Enumerable.Range(1, 10).Select(x => new { ID = x, Name = "Name " + x });
}
In case this is not helpful, please share some more details about the current structure or modify the sample above to make it similar to the setup in question.

Here are some more resources that may also prove helpful:

Kind regards,
Doncho
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
: Arumuga Vignesh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
: Arumuga Vignesh
Top achievements
Rank 1
Umasankar
Top achievements
Rank 1
Veteran
Doncho
Telerik team
Share this question
or