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

Custom command, enter properties.

3 Answers 587 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 09 Jan 2013, 02:42 PM
Hi,

My row is binded to a certain item. I need to give this item as a variable to my custom command. How can I this?

the grid:
<div data-bind="kendoGrid: {
    data: items,
    columns: [
            {width: 90, title: 'Action', command: { text: 'Edit', click: editItem}},
            {field: 'Name',title: 'Name'}]"/>

the script:
editItem = function (item) {
            location.href = 'Item/Edit/' + item.Id;
}
Thus, what I want to do is pass the item (or directly the itemId) to my editItem function. Now item is the created button.
How can I do this?

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 10 Jan 2013, 12:33 PM
Hello Tim,

I'm afraid that you cannot pass custom values to the click handler. However, you may retrieve the data item from within the click handler as shown in this online demo.

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Tim
Top achievements
Rank 1
answered on 11 Jan 2013, 11:57 AM
Ok,

I understand what you are saying. But what I want to accomplish is the same behavior as in this example:
http://demos.kendoui.com/web/grid/editing-popup.html

except in stead of having a popup I want to navigate to an other page. Isn't this possible?
0
Rosen
Telerik team
answered on 11 Jan 2013, 12:50 PM
Hi Tim,

Here is a modified function which combines your initial function with the approach shown in the demo I have pointed.

function editItem(e) {
    e.preventDefault();
 
    var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
    location.href = 'Item/Edit/' + dataItem.Id;
}

Please have in mind that you will need to change the command name to be different then edit, as it is a built-in command name.

command: { text: 'Edit', name: "mycustomcommand", click: editItem}

Regards,
Rosen
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
Tim
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Tim
Top achievements
Rank 1
Share this question
or