Can someone help me in selecting a kendo grid row programmatically in angular. I can select a row by row number. I'm unable to figure out a way to select a row based on one if its column's contents.
HTML:
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
<div kendo-grid="myGrid" k-options="myOptions" k-selectable="'row'" k-on-change="myGridChange()"></div>
</body>
JS:
var app = angular.module('plunker', ['kendo.directives']);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.myOptions = {
columns:[
{
field: 'ID'
},
{
field: 'FirstName'
},
{
field: 'LastName'
},
],
dataSource: [
{ID:139, FirstName:'John', LastName:'Doe'},
{ID:250, FirstName:'Jane', LastName:'Smith'},
{ID:376, FirstName:'Henry', LastName:'Rocks'}
],
dataBound:function(e) {
var grid = e.sender;
grid.select("tr:eq(2)");
grid.select("tr[FirstName='Henry'])"); // This doesn't work
}
};
$scope.myGridChange = function(){
var selectedRows = $scope.myGrid.select(); // This doesn't work
console.log($scope.myGrid.dataItem(selectedRows[0]));
};
});
Also, when a row is selected programmatically, I'm getting an error in my grid change event. It works fine when row is selected manually.
Here is my plunker http://plnkr.co/edit/PpDuSR10xNOxOVirDpfN?p=preview