Making a Kendo Grid link template behave like a command

kendo-grid, kendo-ui

Solution

This is similar to what I use in my own projects. You can use whatever markup you desire and style it however you want to make it look functional.

function showDetails(e) {
    var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
    document.getElementById('details').innerHTML = dataItem.quantity;
}

var data = [
    { name: "name1", quantity: 1 },
    { name: "name2", quantity: 4 },
    { name: "name3", quantity: 9 }
];

var grid = $('#grid').kendoGrid({
    dataSource: data,
    columns: [
        { field: 'name', template: '<a href="\\#" class="k-button link">#= name #</a>' },
        { field: 'quantity' }
    ]
}).data('kendoGrid');

grid.table.on('click', '.link', function(e) {
        showDetails.call(grid, e);
});

JsFiddle

http://jsfiddle.net/qXAf6/7/

Problem

I have a Kendo Grid, and instead of having a custom command: ``` $('#grid').kendoGrid({ dataSource: data, columns: [ ... { command: { text: "Details", click: showDetails }, title: " " } ] }); ``` I'd like the same behavior to occur but on a standard link. Is it possible? This is the functionality I'm looking for: http://jsfiddle.net/dmathisen/ERgkA/2/ But want it to behave like this: http://jsfiddle.net/dmathisen/qXAf6/4/

Original source