executing javascript from a GridHyperLinkColumn

3 posts, 1 answers
  1. Miguel
    Miguel avatar
    16 posts
    Member since:
    Mar 2011

    Posted 09 Dec 2016 Link to this post

    Hi,

    I'm porting some old code to Telerik and I'm having issues. This application has a grid and two of the columns contains hyperlinks that would execute java code to open a non-modal windows to present more details on the items with hyperliks
    In the old code, this solved by a template like this:

    <ItemTemplate>
                  <asp:HyperLink ID="hplnkCatalogDetails" runat="server" ToolTip='Click To View Details'    Text='<%# Eval("ID") %>' NavigateUrl="<%#String.Format(&quot;javascript:void(window.showModalDialog('CatalogDetailsPopUp.aspx?id={0}','','dialogHeight:500px;dialogWidth:850px'));&quot;, Eval(&quot;ID&quot;)) %>" />                                                
    </ItemTemplate>

     

    However this solution fails to execute if using this solution with Telerik GridTemplateColumn :

    <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" HeaderText="Catalog" UniqueName="TemplateColumn" DataField="ID">
                                                            <ItemTemplate>
                                                              <asp:HyperLink ID="hplnkCatalogDetails2" runat="server" ToolTip='Click To View Details'
                                                                        Text='<%# Eval("ID") %>' NavigateUrl="<%#String.Format(& quot;javascript:void(window.showModalDialog     ('CatalogDetailsPopUp.aspx?id={0}','','dialogHeight:500px;dialogWidth:850px'));&quot;, Eval(&quot;ID&quot;)) %>" />
                                                            </ItemTemplate>
                                                        </telerik:GridTemplateColumn>

     

    and this other approach does not work neither using GridHyperLinkColumn:

                                                       
                                                        <telerik:GridHyperLinkColumn AllowSorting="False" DataTextField="ID" FilterControlAltText="Filter column column" HeaderText="Catalog" UniqueName="colID"
                                                          
                                                            NavigateUrl= "&quot;<%#String.Format(& quot;javascript:void(window.showModalDialog('CatalogDetailsPopUp.aspx?id={0}','','dialogHeight:500px;dialogWidth:850px'));&quot;, Eval(&quot;ID&quot;)) %>&quot;"
                                                            DataNavigateUrlFields="ID"
                                                            DataNavigateUrlFormatString="javascript:void(window.showModalDialog('CatalogDetailsPopUp.aspx?id={0}','','dialogHeight:500px;dialogWidth:850px'))" >
                                                           
                                                        </telerik:GridHyperLinkColumn>

     

    How should I address this?

     

     

     

  2. Answer
    Eyup
    Admin
    Eyup avatar
    3740 posts

    Posted 14 Dec 2016 Link to this post

    Hi Miguel,

    Generally, this requirement should be possible with GridTemplateColumn. You can check various ways of declaring link columns in the RadGrid web site provided in the following post:
    http://www.telerik.com/forums/open-report-link-using-unique-row-id#eupACGJdv0mBbLYsQEvMdQ

    And here you can find a list of possible dialog options:
    http://www.telerik.com/forums/context-menu---open-a-pop-up#Qe9fJgzWrE2DhYPWX7OkCQ

    As stated, this implementation can be achieved using GridTemplateColumn. Check once again the definition and try to build the ItemTemplate step by step.

    Regards,
    Eyup
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Miguel
    Miguel avatar
    16 posts
    Member since:
    Mar 2011

    Posted 14 Dec 2016 Link to this post

    Thanks, I found in how to properly doing it with the template column.
Back to Top