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

Bug with client-side databinding and DataNavigateUrlFormatString

1 Answer 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aaron Gibbs
Top achievements
Rank 2
Aaron Gibbs asked on 16 Apr 2013, 03:46 AM
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" />
</telerik:GridHyperlinkColumn>

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.WebResource.axd:12965
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
_onReadyStateChange

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" />
</telerik:GridHyperlinkColumn>

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?

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 18 Apr 2013, 08:16 AM
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"
    DataNavigateUrlFormatString="javascript:OpenJobInfoWindow(\'{0}\');">
    <ItemStyle Width="180" />
</telerik:GridHyperLinkColumn>

Regards,
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.
Tags
Grid
Asked by
Aaron Gibbs
Top achievements
Rank 2
Answers by
Antonio Stoilkov
Telerik team
Share this question
or