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

Display multiple popup on selection of rows in RadGrid

1 Answer 217 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Soumya
Top achievements
Rank 1
Soumya asked on 25 Jun 2015, 06:07 AM

Hi,

I have a requirement to display a radwindow for every selected row in the radgrid. The content of the window is different for each row.
When I select multiple rows and click on a button, I need to display the radwindow one after the other. For example, if I select 5 rows and click on the button, I need to display the window 5 times.

In the button click event, I have the below code. 

foreach (GridDataItem item in grid.SelectedItems)
{
    window.VisibleOnPageLoad = true;
    // Load the content for the window
}
However, the window gets loaded only once after completion of the foreach loop. 

I also tried setting the Visible property of the window instead of using VisibleOnPageLoad. But in this case, the window is not displayed at all. 
Is there a way to display the window first and then continue execution of foreach loop?

Thanks in advance.

Regards,
Sowmya

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 29 Jun 2015, 07:12 AM
Hello Sounmya,

For achieving the desired result you will have to created new RadWIndow object for each selected item in the grid. You can also use RadWindowManager for handling the scenario.

Below is a simple example demonstrating how to create multiple RadWIndows for each selected item in the grid:
<telerik:RadButton runat="server" ID="RadButton1" Text="Show windows" OnClick="RadButton1_Click"></telerik:RadButton>
 
<telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource" AllowMultiRowSelection="true" ClientSettings-Selecting-AllowRowSelect="true">
</telerik:RadGrid>
 
<telerik:RadWindowManager runat="server" ID="RadWindowManager1"></telerik:RadWindowManager>

And the code-behind:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("ID", typeof(int));
    table.Columns.Add("FirstName", typeof(string));
    table.Columns.Add("LastName", typeof(string));
    table.Columns.Add("Age", typeof(int));
    table.Columns.Add("Date", typeof(DateTime));
    table.Columns.Add("BoolValue", typeof(Boolean));
    for (int i = 0; i < 5; i++)
    {
        table.Rows.Add(i, "FirstName" + i, "LastName" + i, 20 + i, DateTime.Now.AddDays(i), i % 2 == 0);
    }
 
    (sender as RadGrid).DataSource = table;
}
 
protected void RadButton1_Click(object sender, EventArgs e)
{
    int count = 0;
    RadWindowManager1.Windows.Clear();
    foreach (GridDataItem item in RadGrid1.SelectedItems)
    {
        RadWindow window = new RadWindow();
        Label testLabel = new Label();
        testLabel.Text = item.ItemIndex.ToString();
        window.ID = "RadWindow" + count;
        window.ContentContainer.Controls.Add(testLabel);
        window.VisibleOnPageLoad = true;
        RadWindowManager1.Windows.Add(window);
        count++;
        //for changing the position of each window
        window.Top = Unit.Pixel((int)Math.Round(200 + window.Top.Value + count * 20));
        window.Left = Unit.Pixel((int)Math.Round(200 + window.Left.Value + count * 20));           
    }
}

Hope this helps.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Soumya
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or