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

[Solved] Open Window from CommandItem

5 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Benjamin Millspaugh
Top achievements
Rank 1
Benjamin Millspaugh asked on 10 Mar 2008, 03:23 PM
I like the default CommandItem template and style but I would like the "Add new record" button to open a new window with a custom form in it.  For most of my grids I can get away with the inline forms, but in this case I really need a new window and I was hoping to just use the existing command buttons in code somehow to open a new window with the form in it.  Is there a way to control the target or action behind that button either in source or programtically without having to create a whole CommandItemTemplate that replicates the built-in functionality?

5 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 12 Mar 2008, 12:55 PM
Hi Benjamin,

To see more information on the requested functionality, please refer to the following article.
I hope this information helps.

All the best,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Benjamin Millspaugh
Top achievements
Rank 1
answered on 12 Mar 2008, 01:13 PM
That article does not address my question at all.  I will repeat my question for you:

Is there a was a way to control the target or action behind that button either in source or programtically without having to create a whole CommandItemTemplate that replicates the built-in functionality?
0
Yavor
Telerik team
answered on 12 Mar 2008, 01:46 PM
Hi Benjamin,

You cannot use the default edit form, and simply open a new window, with the edit form in it. this functionality would require more coding, since the control cannot automatically get the newly inserted data from the editform, or render the edit form in another window. That is why I suggested the other approach.

Greetings,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Benjamin Millspaugh
Top achievements
Rank 1
answered on 12 Mar 2008, 01:54 PM
I did not ask if you could use the default form in a new window (although that would have been very nice).  I asked if there was a way to programatically control the default button to make it do something else (such as open a new window).
0
Yavor
Telerik team
answered on 12 Mar 2008, 02:10 PM
Hello Benjamin,

Yes there is such a way, demonstrated by the code snippet below:

.cs
 protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        GridCommandItem commandItem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];  
        LinkButton addNewRecord = (LinkButton)commandItem.FindControl("InitInsertButton");  
        addNewRecord.Attributes["target"] = "_blank";  
    } 

however, in the bigger context of using this functionality to handle the intended purpose of opening the insert/edit form in a new window, this would not work, and I would suggest using the already suggested approach.

All the best,

Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Benjamin Millspaugh
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Benjamin Millspaugh
Top achievements
Rank 1
Share this question
or