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

How to add an edit hyperlink field on radgrid?

4 Answers 319 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marcus
Top achievements
Rank 1
Marcus asked on 01 Feb 2009, 03:15 PM
Hi,

I have a radgrid that has an editcommandcolumn in the form of a button (ButtonType="PushButton"). This pops-up an edit control (ascx) in the automated way which is all fine.

I want some other fields on my grid-row to hyperlink to the same edit popup. Does anyone knwo how this can be done?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Feb 2009, 05:00 AM
Hello Marcus,

You can either display the edit form on clicking the hyperlink control of a HyperLinkColumn as shown below:
aspx:
<telerik:GridHyperLinkColumn Text="EditDetails" UniqueName="HyperlinkCol"></telerik:GridHyperLinkColumn>  

cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            int index = dataItem.ItemIndex; 
            HyperLink hyplnk = (HyperLink)dataItem["HyperlinkCol"].Controls[0]; 
            hyplnk.Attributes.Add("onClick", "return ShowEditPopUp('" + index + "');");           
        } 
     }   

js:
 function ShowEditPopUp(editedRow) 
    { 
       $find("<%= RadGrid1.MasterTableView.ClientID %>").editItem(editedRow); 
    } 

or you can use a GridButtonColumn with its CommandName set as Edit as shown in the code below:
aspx:
<telerik:GridButtonColumn CommandName="Edit" ButtonType="LinkButton" Text="EditDetails"  UniqueName="column1"
 </telerik:GridButtonColumn> 

Thanks
Princy.
0
Marcus
Top achievements
Rank 1
answered on 02 Feb 2009, 10:32 AM
Thank you Princy. That fixed it!

Marcus.
0
Michael
Top achievements
Rank 2
answered on 06 Jul 2009, 08:53 PM
I have a question related to this. How would you reference a radgrid within a radgrid in the ShowEditPopup function?

Here is my situation: I have a radgrid with an edit popup as a form template. In that popup form I have another radgrid and I would like to have another popup window using the hyperlink column as explained in this forum.

I receive an compile error when I directly reference my second radgrid (rgRadGrid2) in the function:
    function ShowEditPopUp(editedRow)
    {
       $find("<%= rgRadGrid2.MasterTableView.ClientID %>").editItem(editedRow);
    }
Error:
Error    3    'Telerik.Web.UI.RadGrid' does not contain a definition for 'rgRadGrid2' and no extension method 'rgRadGrid2' accepting a first argument of type 'Telerik.Web.UI.RadGrid' could be found (are you missing a using directive or an assembly reference?)  

So I am assuming that I have to reference radgrid1 first and then within this one establish a reference to radgrid2. I have tried various alternatives but no success. Any help would be greatly appreciated.

Thanks,

Michael Kremer  

0
Michael
Top achievements
Rank 2
answered on 10 Jul 2009, 03:53 PM
Is there anyone who can help me. I am trying to reference a detailtable in JS. I have searched this form, tried various alternatives, but nothing worked:
Here is what I thought would work:
       $find("<%= rgXray.MasterTableView.DetailTables[0].ClientID %>").editItem(editedRow);
But this does not work. I cannot imagine that this is so hard to do.

Again, any help is much appreciated.

Thanks,
Michael Kremer

Tags
Grid
Asked by
Marcus
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Marcus
Top achievements
Rank 1
Michael
Top achievements
Rank 2
Share this question
or