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

MVC Grid hierarchy - add link to javascript function on child grid column

4 Answers 492 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matias
Top achievements
Rank 1
Matias asked on 07 Apr 2016, 03:40 PM

I'm trying to add a onClick JS function to a certain column in the child grid, but so far with no luck.

 

This is my column:

columns.Bound(o => o.oper_numero).Width(110).ClientTemplate("<a onclick=\"showDetails('#=oper_numero#')\" href='\\#'>#=oper_numero#</a>");

I achieved the desired functionality with both a non hiearchy grid and the parent grid.

I've read that I have to escape the the # symbol in the child grid, but I've tried every combination and still doesn't work. This for example doesn't work:

columns.Bound(o => o.oper_numero).Width(110).ClientTemplate("<a onclick=\"showDetails('#=oper_numero#')\" href='\\#'>\\#'=oper_numero\\#'</a>");
columns.Bound(o => o.oper_numero).Width(110).ClientTemplate("<a onclick=\"showDetails('\\#'=oper_numero\\#'')\" href='\\#'>#=oper_numero#</a>");
columns.Bound(o => o.oper_numero).Width(110).ClientTemplate("<a onclick=\"showDetails('\\#'=oper_numero\\#'')\" href='\\#'>\\#=oper_numero\\#</a>");

I'd like to know what I'm doing wrong.

Thanks a lot

4 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 08 Apr 2016, 09:20 AM

Hello Matias,

The reason for the issue is the hash symbol in the href attribute, which is not part of the template syntax. Here is the correct way to define the link on the second Grid level in this case.
E.g.

.ClientTemplate("<a href='\\\\\\#' onclick=\"showDetails('\\#=oper_numero\\#')\">\\#=oper_numero\\#</a>")

Regards,
Dimiter Madjarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Matias
Top achievements
Rank 1
answered on 13 Apr 2016, 07:27 PM
It works fine. Thanks a lot.
0
PRASHANT
Top achievements
Rank 1
answered on 21 Sep 2017, 10:52 AM
Is there any way to open bootstrap model popup with link
0
Stefan
Telerik team
answered on 25 Sep 2017, 07:28 AM
Hello, Prashant,

I can suggest checking the following forum post and a similar subject, as it contains information how it can be achieved:

http://www.telerik.com/forums/opening-bootstrap-modal-from-url-in-grid-column

I hope this is helpful.

Regards,
Stefan
Progress Telerik
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.
Tags
Grid
Asked by
Matias
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Matias
Top achievements
Rank 1
PRASHANT
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or