<!DOCTYPE html>
<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="spike">
<head>
<!--
This page can be used as a base for spiking with jQuery, AngularJS and Kendo.
All scripts and styles are loaded from a CDN or inline.
-->
<title>Spike page</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"><!-- Use highest support for modern standards . -->
<!-- Library styles -->
<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.silver.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.silver.mobile.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.dataviz.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.dataviz.silver.min.css" rel="stylesheet" />
<!-- Library scripts -->
<script src="http://cdn.kendostatic.com/2014.2.1008/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.2.1008/js/angular.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.2.1008/js/kendo.all.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.2.1008/js/cultures/kendo.culture.nl-NL.min.js"></script>
<!-- Live reload script with grunt. -->
<script src="http://localhost:35729/livereload.js"></script>
<!-- App styles -->
<style>
/*
A small custom reset stylesheet is used, to fix style differences between browsers.
*/
html, body {
height: 100%; /* App layout uses a 100% height layout. */
}
body, div, input, li, p, select, ul {
border: 0; /* Remove unwanted space. */
-webkit-box-sizing: border-box; /* Place the border and padding inside the box. */
-moz-box-sizing: border-box; /* Place the border and padding inside the box. */
-ms-box-sizing: border-box; /* Place the border and padding inside the box. */
-o-box-sizing: border-box; /* Place the border and padding inside the box. */
box-sizing: border-box; /* Place the border and padding inside the box. */
font-family: "Open Sans", sans-serif;
font-size: 15px;
margin: 0; /* Remove unwanted space. */
outline: 0; /* Remove unwanted space. */
padding: 0; /* Remove unwanted space. */
}
body {
padding: 20px; /* Create space between browser border and content. */
min-width: 320px; /* App will not work beneath width: 320px. */
}
.disabled{
color: red;
font-size: medium;
}
.active{
color: green;
font-size: larger;
}
</style>
<!-- App scripts -->
<script>
(function () {
"use strict";
// This is the starting point (main) for the angular app.
var app = angular.module("spike", ["kendo.directives"]).directive('gridCell', function () {
return {
restrict: 'E',
template:"<div><span ng-show='readOnly' ng-bind='modelValue'></span><span ng-attr-controlType='controlType'></span></div>",
scope: {
cellInfo:'=',
columnInfo:'=',
modelValue:'=',
fullModel:'='
},
link: function (scope, element, attrs) {
scope.readOnly=true;
$(element).bind('dblclick',function(){
alert("Double Click");
scope.readOnly=false;
$(element).find("[controlType='"+scope.cellInfo.controlType+"']").appendTo("");
})
$(element).find("[controlType='"+scope.cellInfo.controlType+"']").bind('focusout',function(){
scope.readOnly=true;
});
}
};
});
// Set culture info to Ducth:
kendo.culture("nl-NL");
}());
(function () {
"use strict";
var app = angular.module("spike");
var controller = function ($scope, service) {
$scope.cellInfo={dataType:'string',controlType:'WWTextEdit'}
$scope.columnInfo={}
$scope.title = "Using a Kendo grid row template and paging with AngularJS.";
$scope.tasks = {
data: [
{ "name": "ToDo - 1", "date": "21-07-2014" },
{ "name": "ToDo - 2", "date": "20-08-2014" },
{ "name": "ToDo - 3", "date": "09-04-2014" },
{ "name": "ToDo - 4", "date": "21-07-2014" },
{ "name": "ToDo - 5", "date": "08-01-2014" },
{ "name": "ToDo - 6", "date": "21-02-2014" }
],
pageSize: 5
};
$scope.tasksModified = {
data: [
{ "name": {value:"ToDo - 1", isVisible:true}, "date": {value:"21-07-2014", isVisible:true} },
{ "name": {value:"ToDo - 2",isVisible:true}, "date": {value:"20-08-2014",isVisible:true} },
{ "name": {value:"ToDo - 3", isVisible:true}, "date":{value:"09-04-2014", isVisible:true} },
{ "name": {value:"ToDo - 4", isVisible:true}, "date":{value: "21-07-2014",isVisible:true} },
{ "name": {value:"ToDo - 5",isVisible:true}, "date": {value:"08-01-2014",isVisible:true} },
{ "name": {value:"ToDo - 6",isVisible:true}, "date": {value:"21-02-2014",isVisible:true} }
],
pageSize: 5
};
$scope.EvaluateVisible=function(data){
console.log("Method executed",data);
if(data.name.value=="hide"){
data.date.isVisible=false;
console.log(data.date);
}
else{
data.date.isVisible=true;
}
return data.date.isVisible;
}
$scope.addWWDateEditEditor= function (container, options) {
console.log("Editor Launched", options);
$(container).append('<input type="text" ng-model="options.model.date.value">- test');
}
$scope.addWWNameEditor= function (container, options) {
console.log("Editor Launched", options);
$(container).append('<input type="text" ng-model="options.model.name.value">- test');
}
$scope.addWWDateEditEditor= function (container, options) {
console.log("Editor Launched", options);
$(container).append('<input type="text" ng-model="options.model.date.value">- test');
}
$scope.rowTemplate = kendo.template($("#rowTemplate").html());
console.log($scope.rowTemplate);
$scope.columns=[{ field: 'name', title: 'Name' },
{ field: 'date', title: 'Date' },
{ title: 'Static' }];
};
app.controller("main", ["$scope", controller]);
}());
</script>
</head>
<body>
<div ng-controller="main">
<hr>
<span>Test</span>
<hr>
<h2>{{ title }}</h2>
<div>
<br />
<script id="rowTemplate" type="text/x-kendo-tmpl">
<tr data-uid="#: uid #">
<td ng-repeat='col in columns'>
<div ng-if="col.field=='name'">
<input type="text" name="input"
ng-model="dataItem[col.field].value" >
<!--<span ng-model="dataItem[col.field].value" >{{dataItem[col.field].value}}</span>-->
<!--<span ng-class="dataItem[col.field].isVisible ? 'active' : 'disabled'">- Some static text1</span>/-->
<span>- Some static text1</span>
</div>
<div ng-if="col.field=='date'">
<span ng-model="dataItem[col.field].value" >{{dataItem[col.field].value}}</span>
<span ng-show="EvaluateVisible(dataItem)">- Some temp text</span>
</div>
</td>
</tr>
</script>
<div id="grid" kendo-grid
k-columns="columns"
k-data-source="tasksModified"
k-pageable="{
pageSizes: [5, 20]
}"
k-editable="true"
k-row-template="rowTemplate"
k-sortable="true"></div>
</div>
</div>
</body>
</html>
// Code goes here
/* Styles go here */
.disabled{
color: red;
font-size: medium;
}
.active{
color: green;
font-size: larger;
}