This question is locked. New answers and comments are not allowed.
Hi,
I am creating columntemplate in telerik MVC grid with below code-
columns.Bound(a => a.Id).ClientTemplate("<a onclick='viewDetails('" + "'<#= Id #>'" + "');' href='javascript:'>View</a>").Title("View");
and this is my function in javascript -
function viewDetails(activityId) {
//....Do stuff here...
}
Now the issue that i am facing is, the javascript function viewDetails is not getting called and on page load i am getting javascript error and the description says "syntax error: expected ("
When i remove the method parameter and instead use rel attribute like -
columns.Bound(a => a.Id).ClientTemplate("<a onclick='viewDetails();' rel='<#= Id #>' href='javascript:'>View</a>").Title("View");
and write my method like -
function viewDetails() {
var activityId = $(this).attr('rel'); //----- activityId is always null
//....Do stuff here...
}
The method gets called but activityId is always null in the method
Can anyone please let me know how can i pass my row id from grid column template to the javascript method?
Thanks
Alpesh
I am creating columntemplate in telerik MVC grid with below code-
columns.Bound(a => a.Id).ClientTemplate("<a onclick='viewDetails('" + "'<#= Id #>'" + "');' href='javascript:'>View</a>").Title("View");
and this is my function in javascript -
function viewDetails(activityId) {
//....Do stuff here...
}
Now the issue that i am facing is, the javascript function viewDetails is not getting called and on page load i am getting javascript error and the description says "syntax error: expected ("
When i remove the method parameter and instead use rel attribute like -
columns.Bound(a => a.Id).ClientTemplate("<a onclick='viewDetails();' rel='<#= Id #>' href='javascript:'>View</a>").Title("View");
and write my method like -
function viewDetails() {
var activityId = $(this).attr('rel'); //----- activityId is always null
//....Do stuff here...
}
The method gets called but activityId is always null in the method
Can anyone please let me know how can i pass my row id from grid column template to the javascript method?
Thanks
Alpesh