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

5 posts, 1 answers
  1. Jerry Chen
    Jerry Chen avatar
    9 posts
    Member since:
    Nov 2009

    Posted 22 Feb 2010 Link to this post

    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
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Feb 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jerry Chen
    Jerry Chen avatar
    9 posts
    Member since:
    Nov 2009

    Posted 22 Feb 2010 Link to this post

    Haha, it does work. Thank you so much, Shinu, thank you for your help.
  5. bslaght
    bslaght avatar
    184 posts
    Member since:
    Jun 2006

    Posted 03 Mar 2010 Link to this post

    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.
  6. bslaght
    bslaght avatar
    184 posts
    Member since:
    Jun 2006

    Posted 03 Mar 2010 Link to this post

    Got it figurted out.

     <script type="text/javascript">  
                function RowDblClick(sender, eventArgs) {  
                    window.location.replace("client.aspx?ID=" + eventArgs.getDataKeyValue("ID"));  
     
                }  
            </script> 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017