<html>
<head>
<meta name="description" content="Kendo Grid MVVM DetailInit RowTemplate Tooltip" />
<link href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.rtl.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.dataviz.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.dataviz.default.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2013.2.716/js/kendo.all.min.js"></script>
<title>JS Bin</title>
</head>
<body>
<div id="gridContainer">
<div id="grid"
data-role="grid"
data-scrollable= "false"
data-detail-init="viewModel.detailInit"
data-row-Template="rowTemplate"
data-columns='[{ title: "Widget Name" }, { title: "Enterprise", width: 85 }, { title: "HQ", width: 85 }, { title: "Office1", width: 75 }, { title: "Office2", width: 75 }, { title: "Office3", width: 75 }, { title: "Office4", width: 75 }, { title: "Office5", width: 75 }, { title: "Office6", width: 75 }, { title: "Office7", width: 75 }, { title: "Office8", width: 75 }]'
data-bind="source: itemsDataSource">
</div>
</div>
<script id="rowTemplate" type="text/x-kendo-template">
<tr class="assignment-table-row1 k-master-row" data-categoryName="#=name#">
<td class="k-hierarchy-cell">
# if(data.SubValues !== undefined && data.SubValues.length > 0) { #
<a class="k-icon k-plus" href="\\#" tabindex="-1"></a>
# } else { #
# } #
</td>
<td class="name">#=data.Name#</td>
# for(var i = 0; i < data.Metrics.length; i++) { #
<td class="value">
<div class="valueMarker" data-color="#=data.Metrics[i].Color#" style="background-color: #=data.Metrics[i].Color#">
</div>
</td>
# } #
</tr>
</script>
</body>
</html>
#gridContainer
{
width: 1050px;
}
.k-grid tbody tr
{
height: 40px !important;
}
.k-grid td
{
border: none;
padding-right: 0em !important;
}
.valueMarker
{
height: 30px;
width: 30px;
margin: auto;
border-radius: 25px;
text-align: center;
color: white;
cursor: pointer;
position:relative;
}
.valueMarker[data-color="White"]
{
border: thin solid black;
}
var data = [{
Name: 'Engineering', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '1', Tooltip: '15% Bad' },
{ PM: 'Office2', Color: 'Red', Text: '3', Tooltip: '67% Bad' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '1', Tooltip: '21% Bad' },
{ PM: 'Office5', Color: 'Red', Text: '4', Tooltip: '85% bad' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '1', Tooltip: '12% Bad' },
{ PM: 'Office8', Color: 'Red', Text: '5', Tooltip: '74% Bad' }
], SubValues: [
{
Name: 'KPP', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: 'Yellow' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: 'Yellow' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' }
]
},
{
Name: 'TRA', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' }
]
},
{
Name: 'Software Metrics', Metrics: [
{ PM: 'PEOAll', Color: '', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: '', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' }
]
}
]
},
{
Name: 'IM/IA', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
], SubValues: [
{
Name: 'Incidents (3 MO)', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
]
}, {
Name: 'Up Time', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
]
}, {
Name: 'Customer Satisfaction', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
]
}, {
Name: 'DIACAP Status', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
]
}, {
Name: 'Mobile Billing', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
]
}
]
},
{
Name: 'Programmatics', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
], SubValues: [
{
Name: 'Assessments', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'PEOAll', Color: 'Red', Text: '', Tooltip: '' }
]
}
]
},
{
Name: 'SPO', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
], SubValues: [
{
Name: 'LSS Training', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
], SubValues: [
{
Name: 'Yellow Belt Training', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
]
},
{
Name: 'Green Belt Training', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
]
},
{
Name: 'Black Belt Training', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
]
}
]
},
{
Name: 'SCG', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
]
},
{
Name: 'Work Order Surveys', Metrics: [
{ PM: 'PEOAll', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'PEOStaff', Color: 'White', Text: '', Tooltip: '' },
{ PM: 'Office1', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office2', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office3', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office4', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office5', Color: 'Red', Text: '', Tooltip: '' },
{ PM: 'Office6', Color: 'Green', Text: '', Tooltip: '' },
{ PM: 'Office7', Color: 'Yellow', Text: '', Tooltip: '' },
{ PM: 'Office8', Color: 'Red', Text: '', Tooltip: '' }
]
}
]
}
];
var viewModel = kendo.observable({
itemsDataSource: new kendo.data.DataSource({
data: data
}),
detailInit: function(e) {
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: e.data.SubValues,
rowTemplate: kendo.template($("#rowTemplate").html()),
detailInit: viewModel.detailInit,
scrollable: false,
columns: [
{ title: "Widget Name" },
{ title: "Enterprise", width: 85 },
{ title: "HQ", width: 85 },
{ title: "Office1", width: 75 },
{ title: "Office2", width: 75 },
{ title: "Office3", width: 75 },
{ title: "Office4", width: 75 },
{ title: "Office5", width: 75 },
{ title: "Office6", width: 75 },
{ title: "Office7", width: 75 },
{ title: "Office8", width: 75 }
]
});
kendo.bind($("div", e.detailCell));
}
});
kendo.bind($(document.body), viewModel);
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |