How can I bind selectedItems in kendoGrid?

273 views Asked by At

I'm using Rniemeyer's kncokout-kendo.js http://rniemeyer.github.io/knockout-kendo/web/Grid.html

I've 'People' and I need to get selected Person.

<div id="grid" style="width:450px" data-bind="kendoGrid: {height:400,columns:['Id','Name'],navigatable:true,selectable:true,rowTemplate: 'rowTmpl', useKOTemplates: true,data: People, select: SelectedPerson,value:SelectedPerson }" ></div>

neither 'select' nor 'value' works.

People is observableArray

The example does not work both SelectedPerson is observable, SelectedPerson is observableArray.

1

There are 1 answers

0
Jeroen On BEST ANSWER

I'm not familiar with Kendo, but judging from this existing fiddle I think you need to use the change option as part of your grid configuration:

kendoGrid: { change: function (event) {
                         self.selectedData(this.dataItem(this.select()[0]));
                     }
}

See this fiddle which contains the code from the question (with a few options commented out because no View code was posted in the question).