var app = angular.module('app', ['ngTouch', 'ui.grid']);
app.controller('MainCtrl', ['$scope', '$http', '$timeout', '$interval', function ($scope, $http, $timeout, $interval) {
// you could of course just include the template inline in your code, this example shows a template being returned from a function
function rowTemplate() {
return '<div ng-dblclick="grid.appScope.rowDblClick(row)" >' +
' <div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader }" ui-grid-cell></div>' +
'</div>';
}
$scope.rowDblClick = function( row) {
alert(JSON.stringify(row.entity));
};
$scope.waiting = 'Double click on any row to seed the row data';
$http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/100.json')
.success(function (data) {
data.forEach( function(row, index) {
row.widgets = index % 10;
});
$scope.data = data;
});
$scope.gridOptions = {
enableFiltering: true,
rowTemplate: rowTemplate(),
data: 'data',
columnDefs: [
{ name: 'name' },
{ name: 'gender' },
{ name: 'company' },
{ name: 'widgets' }
]
};
}]);
.grid {
width: 500px;
height: 300px;
}
.my-css-class { color: blue }
/* --- ui-grid ------- row hover highlight ----- */
.ui-grid-row:hover .ui-grid-cell {
background-color: #ff8476;
}
/* ==== both works ===== */
/*
.ui-grid-row:nth-child(odd):hover .ui-grid-cell{background:red}
.ui-grid-row:nth-child(even):hover .ui-grid-cell{background:red}
*/
/* --- End ----- ui-grid ------- row hover highlight ----- */
<!doctype html>
<html ng-app="app">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-touch.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-animate.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script>
<script src="http://ui-grid.info/release/ui-grid-unstable.js"></script>
<link rel="stylesheet" href="http://ui-grid.info/release/ui-grid-unstable.css" type="text/css">
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body>
<div ng-controller="MainCtrl">
<strong ng-bind="waiting"></strong> <strong>{{ wait }}</strong>
<br>
<div class="grid" ui-grid="gridOptions" ></div>
</div>
<script src="app.js"></script>
</body>
</html>