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

Mapping Grid's Custom Command to the Function of the Row's ViewModel Object

2 Answers 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bojan
Top achievements
Rank 1
Bojan asked on 11 Aug 2015, 01:46 PM

Lets say I have a ViewModel (pseudo code):

MyViewModel​: ObservableObject {

    myItems: ObservableArray<MyItemViewModel> 
}

MyItemViewModel: ObservableObject {

    myFunction: function() {

        // Some code here...

    }

}

Then, if I make an instance of MyViewModel the dataSource of Kendo Grid, what would the syntax for mapping each row's custom command to myFunction be? I can (as in examples) map to inline function that will then find nearest tr and it's dataItem, then call the function - but I would rather like it (if possible) to map it directly to the function of each row's ViewModel... Any ideas?

 

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 13 Aug 2015, 09:56 AM
Hello,

The custom command click handler cannot be mapped to a function from the dataItem but you could use a template with a button and click binding. I created an example that demonstrates this approach.

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Bojan
Top achievements
Rank 1
answered on 14 Aug 2015, 07:06 PM
Thank you, Daniel. That's what I was looking for!
Tags
Grid
Asked by
Bojan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Bojan
Top achievements
Rank 1
Share this question
or