Can someone help me in choosing a kendo grid line programmatically in angular. I can choose line by line. I cannot determine how to select a row based on one if the contents of a column.
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'])");
}
};
$scope.myGridChange = function(){
var selectedRows = $scope.myGrid.select();
console.log($scope.myGrid.dataItem(selectedRows[0]));
};
});
Also, when a row is selected programmatically, I get an error in the grid change event. It works great when a row is manually selected.
Here is my plunker
http://plnkr.co/edit/PpDuSR10xNOxOVirDpfN?p=preview
source
share