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

Custom InsertCommand

5 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raimund
Top achievements
Rank 1
Raimund asked on 29 Jul 2011, 01:21 PM
Hi,

I want to open a radWindow when i click the "Add New Row" Button. I know, i could use a Hyperlink (custom commanditem) - this would be an option if i could use the default style of the Insert Button.

I already stopped the default Insert Event with this code.
protected void gvUser_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.InitInsertCommandName)
    {
        e.Canceled = true;
           ... some code ...
    }
}

In the ItemCreaded Event I tried to add a "onclick" event, but this wont work.
protected void gvUser_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
 {
     if (e.Item is GridCommandItem)
     {
         LinkButton addButton = e.Item.FindControl("InitInsertButton") as LinkButton;
         addButton.Attributes["onclick"] = "return ShowInsertForm();";
     }
}

This is my javascript function.
function ShowInsertForm() {
    window.radopen("Bearbeiten.aspx?umleitung=-1", "rwBearbeiten");
    return false;
}

And this is my radWindowManager
<telerik:RadWindowManager ID="rwmBearbeiten" runat="server" EnableShadow="true">
    <Windows>
        <telerik:RadWindow ID="rwBearbeiten" runat="server" ShowContentDuringLoad="false"
            Width="800px" Height="650px" Title="Bearbeite Umleitungsdaten" Behaviors="Default"
            Modal="true" ReloadOnShow="true">
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>

I dont have another idea, how i can solve this - i really want to keep the default style of the commanditem - it looks really great.


Best regards,
Raimund

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Jul 2011, 01:37 PM
Hello Raimund,

You can try the folowing code snippet to open Window in InitInsertCommandName.
C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
  if (e.CommandName == RadGrid.InitInsertCommandName)
  {
     e.Canceled = true;
     RadWindow win = new RadWindow();
     win.ID = "win1";
     win.VisibleOnPageLoad = true;
     rwmBearbeiten.Controls.Add(win);
  }
}

Thanks,
Princy.
0
Raimund
Top achievements
Rank 1
answered on 29 Jul 2011, 01:48 PM
Hello Princy,

thank you for your fast answer!

I already got this code
    protected void gvUser_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.InitInsertCommandName)
        {
            e.Canceled = true;
 
            Telerik.Web.UI.RadWindow newwindow = new Telerik.Web.UI.RadWindow();
            newwindow.ID = "rwBearbeiten";
            newwindow.NavigateUrl = "Bearbeiten.aspx?umleitung=-1";
            newwindow.Height = 650;
            newwindow.Width = 800;
            newwindow.Modal = true;
            newwindow.VisibleOnPageLoad = true;
 
            rwmBearbeiten.Windows.Clear();
            rwmBearbeiten.Windows.Add(newwindow);
        }
}

The Problem is - i got two windows - one window when i click "Edit" (a hyperlink in each row) and another one when inserting. I often click Insert and / or Edit - so i have to clear the radWindowManager - but when i clear the radWindowManager - the Window I created in the aspx file is also away.
The next time I click Edit - the window got no Settings (width, height, ...)

Ok this is a little bit confuse but I hope you understand where the problem is : /

Best regards,
Raimund
0
Accepted
Vasil
Telerik team
answered on 03 Aug 2011, 04:00 PM
Hi Raimund,

Width and Height properties of the RadWindow  are of type Unit. Try this code:
newwindow.Height = new Unit(650);
newwindow.Width = new Unit(800);

Kind regards,
Vasil
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Raimund
Top achievements
Rank 1
answered on 05 Aug 2011, 12:42 PM
Thank you Vasil,

i think everything works fine now.
Good to know that ive to create a new object.

Best Regards,
Raimund
0
ming
Top achievements
Rank 1
answered on 18 Aug 2011, 11:18 AM
I use the control in 2009, and the implementation rwmBearbeiten.Windows.Add (newwindow) that pops up after Radwindow interface? I have no side effects.I want to know which way to open the radwindow.
Thanks
Tags
Grid
Asked by
Raimund
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Raimund
Top achievements
Rank 1
Vasil
Telerik team
ming
Top achievements
Rank 1
Share this question
or