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

How wo double click on a row to open a new page based on a field with hyperlink?

4 Answers 273 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jerry Chen
Top achievements
Rank 1
Jerry Chen asked on 22 Feb 2010, 06:07 AM
Hello,

      I create a RadGrid programmaticly and define the bound fields, one of which is a GridHyperLinkColumn  below:
GridHyperLinkColumn siteLink = new GridHyperLinkColumn(); 
string[] siteLinkUrlFields = new String[1]; 
siteLinkUrlFields[0] = "SiteURL"; 
siteLink.DataNavigateUrlFields = siteLinkUrlFields
siteLink.DataTextField = "Title"
siteLink.HeaderText = "Site Name"
siteLink.UniqueName = "SiteName"
siteLink.SortExpression = "Title"
siteLink.Target = "_blank"
grid.MasterTableView.Columns.Add(siteLink); 
       Now I'm gonna double click on a row that a new window will show up based on the hyperlink's target site. I have already set grid.ClientSettings.ClientEvents.OnRowDblClick = "RowDblClick";

       How to accomplish the client script to get the navigatorUrl of the hyperlink and redirect. Hence, another approach is provided to users if they don't want to click on the hyperlink.

       I think the client script should be like this:

       function RowDblClick(sender, eventArgs)
       {
              var dataItem = eventArgs.get_dataItem();
              ........................................
              ........................................
              window.open();
       }

Any suggestion is appreciated.
TIA
BR

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 22 Feb 2010, 07:00 AM
Hai Jerry,

Try the following client side code.

Client code:
 
    function RowDblClick(sender, eventArgs) { 
        var grid = sender; 
        var MasterTable = grid.get_masterTableView(); 
        var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()]; 
        var cell = MasterTable.getCellByColumnUniqueName(row, "SiteName"); 
        var url = cell.getElementsByTagName("a")[0].href; 
        if (url != null) { 
            window.open(url); 
        }         
    } 

Happy coding,
Shinu
0
Jerry Chen
Top achievements
Rank 1
answered on 22 Feb 2010, 07:10 AM
Haha, it does work. Thank you so much, Shinu, thank you for your help.
0
Brett
Top achievements
Rank 2
answered on 03 Mar 2010, 03:24 PM
Hi Shinu,
 I am looking to accomplish the same sort of thing.  But what I want to do is double click on a row, and then direct user to a new page which contains a formview to edit the row data.

I am thinking, server.transfer (newpage.aspx?recordID=123) to update the query string with the selected recordID send to new page.  Formview opens reocrd based on Query String.

Can't seem to make this work.
0
Brett
Top achievements
Rank 2
answered on 03 Mar 2010, 03:43 PM
Got it figurted out.

 <script type="text/javascript">  
            function RowDblClick(sender, eventArgs) {  
                window.location.replace("client.aspx?ID=" + eventArgs.getDataKeyValue("ID"));  
 
            }  
        </script> 
Tags
Grid
Asked by
Jerry Chen
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jerry Chen
Top achievements
Rank 1
Brett
Top achievements
Rank 2
Share this question
or