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

Call a javascript function from a template passing parameters to the function

1 Answer 658 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Juan
Top achievements
Rank 1
Juan asked on 17 Apr 2013, 05:43 PM
I have a grid that have a template column with an anchor to open a window popup when it is click. I need to pass the id of the line where I'm clicking the anchor, but I can get how to pass that value.

I'm attaching my code


@(Html.Kendo().Grid(Model.QuoteRequests)
                .Name("MultilineGrid")
                .Resizable(resizable => resizable.Columns(true))
                .Scrollable()
                .EnableCustomBinding(true)
                .Selectable(selectable => selectable
                    .Mode(GridSelectionMode.Multiple))
                    
                .Columns(columns => {
                    columns.Bound(qr => qr.QuoteRequestId).Hidden();
                    columns.Template(@<text><a href="#" onclick= "OpenNotes(#=QuoteRequestId#)" class = 'k-button k-button-icontext'> Notes </a></text>).Width(100);
                    }
                })

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 18 Apr 2013, 09:04 AM
Hi Juan,


This is a quote from my answer in the support thread


In a server template you could refer to the model for the current row with the item property.
E.g.

columns.Bound(p => p.UnitsInStock).Template(@<text><a href="#" onclick= "OpenNotes(@item.CategoryID)">link</a></text>);



Wish you a great day!
 

All the best,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Juan
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or