Creating a link template in a Kendo grid behaves like a team

I have a Kendo grid and instead of a user command:

$('#grid').kendoGrid({
    dataSource: data,
    columns:
    [
        ...
        { command: { text: "Details", click: showDetails }, title: " " }
    ]
});

I would like the same behavior to happen, but using the standard link. Is it possible?

This is the functionality I'm looking for: http://jsfiddle.net/dmathisen/ERgkA/2/

But you need it to behave like this: http://jsfiddle.net/dmathisen/qXAf6/4/

+3
source share
1 answer

This is similar to what I use in my projects. You can use any markup you want and style it, but you want it to 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/

+5
source

All Articles