Bug with client-side databinding and DataNavigateUrlFormatString

2 posts, 0 answers
  1. Aaron Gibbs
    Aaron Gibbs avatar
    23 posts
    Member since:
    Dec 2007

    Posted 15 Apr 2013 Link to this post

    I am having trouble getting the DataNavigateUrlFormatString to work properly with client-side databinding.

    I am binding the RadGrid client-side to a serialized collection of JSON objects.  One of the object's properties is a JobID, which is a string representation of a GUID such as 'E45FA7DC-EAE5-4443-B72D-806D18FAE428'

    I need to pass this string to a Javascript function, I am using a GridHyperlinkColumn in the RadGrid to do this:

    <telerik:GridHyperlinkColumn DataTextField="JobStatus" HeaderText="Job Status" DataNavigateUrlFields="JobID"
            DataNavigateUrlFormatString="javascript:OpenJobInfoWindow('{0}');" >
        <ItemStyle Width="180" />

    I am getting the Javascript error "Unexpected token {" after calling the mastertableview.dataBind() function in Javascript (Google Chrome):
    Uncaught SyntaxError: Unexpected token {
    Telerik.Web.UI.GridTableView._prepareHyperLinkColumnElement Telerik.Web.UI.WebResource.axd:12965
    Telerik.Web.UI.GridTableView.dataBind Telerik.Web.UI.WebResource.axd:12883
    RefreshSummaryCallback Status.aspx:216
    l Telerik.Web.UI.WebResource.axd:6
    (anonymous function) Telerik.Web.UI.WebResource.axd:6
    Sys.Net.WebRequest.completed Telerik.Web.UI.WebResource.axd:6

    This appears to have to do with the DataNavigateUrlFormatString.  From what I can tell, it specifically has to do with having single quotes around the {0} placeholder in the DataNavigateUrlFormatString property of the RadGridHyperlinkColumn.  If I remove these, everything binds correctly:
    <telerik:GridHyperlinkColumn DataTextField="JobStatus" HeaderText="Job Status" DataNavigateUrlFields="JobID"
            DataNavigateUrlFormatString="javascript:OpenJobInfoWindow({0});" >
        <ItemStyle Width="180" />

    Problem is, I have to have the single quotes there, since the value I am passing as a parameter to OpenJobInfoWindow is a string.  What can I do to make this work?
  2. Antonio Stoilkov
    Antonio Stoilkov avatar
    530 posts

    Posted 18 Apr 2013 Link to this post

    Hello Aaron,

    In order to resolve your issue you could escape the single quotes as shown below. Additionally, I have assembled a sample page showing the behavior working on my side.
    <telerik:GridHyperLinkColumn DataTextField="JobStatus" HeaderText="Job Status" DataNavigateUrlFields="JobID"
        <ItemStyle Width="180" />

    Antonio Stoilkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top