Skip to content

Instantly share code, notes, and snippets.

@adriatic

adriatic/app.html

Last active Aug 16, 2020
Embed
What would you like to do?
ListView:editing
<template>
<require from="./editing.css"></require>
<a class="k-button ak-button-icontext k-add-button" href="#"><span class="k-icon k-add"></span>Add new record</a>
<div id="listview-editing">
<ak-list-view k-data-source.bind="dataSource">
<ak-template>
<div class="product-view k-widget" data-uid="${uid}">
<dl>
<dt>Product Name</dt>
<dd>${ProductName}</dd>
<dt>Unit Price</dt>
<dd>${UnitPrice}</dd>
<dt>Units In Stock</dt>
<dd>${UnitsInStock}</dd>
<dt>Discontinued</dt>
<dd>${Discontinued}</dd>
</dl>
<div class="edit-buttons">
<a class="k-button k-edit-button"><span class="k-icon k-edit"></span></a>
<a class="k-button k-delete-button"><span class="k-icon k-delete"></span></a>
</div>
</div>
</ak-template>
<ak-template for="editTemplate">
<div class="product-view k-widget">
<dl>
<dt>Product Name</dt>
<dd>
<input type="text" class="k-textbox" data-bind="value:ProductName" name="ProductName" required="required" validationMessage="required" />
<span data-for="ProductName" class="k-invalid-msg"></span>
</dd>
<dt>Unit Price</dt>
<dd>
<input type="text" data-bind="value:UnitPrice" data-role="numerictextbox" data-type="number" name="UnitPrice" required="required" min="1" validationMessage="required" />
<span data-for="UnitPrice" class="k-invalid-msg"></span>
</dd>
<dt>Units In Stock</dt>
<dd>
<input type="text" data-bind="value:UnitsInStock" data-role="numerictextbox" name="UnitsInStock" required="required" data-type="number" min="0" validationMessage="required" />
<span data-for="UnitsInStock" class="k-invalid-msg"></span>
</dd>
<dt>Discontinued</dt>
<dd><input type="checkbox" name="Discontinued" data-bind="checked:Discontinued"></dd>
</dl>
<div class="edit-buttons">
<a class="k-button k-update-button"><span class="k-icon k-update"></span></a>
<a class="k-button k-cancel-button"><span class="k-icon k-cancel"></span></a>
</div>
</div>
</ak-template>
</ak-list-view>
<div ref="pager" class="k-pager-wrap"></div>
</div>
</template>
export class Editing {
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: '//demos.telerik.com/kendo-ui/service/Products',
dataType: 'jsonp'
},
update: {
url: '//demos.telerik.com/kendo-ui/service/Products/Update',
dataType: 'jsonp'
},
destroy: {
url: '//demos.telerik.com/kendo-ui/service/Products/Destroy',
dataType: 'jsonp'
},
create: {
url: '//demos.telerik.com/kendo-ui/service/Products/Create',
dataType: 'jsonp'
},
parameterMap: function(options, operation) {
if (operation !== 'read' && options.models) {
return {models: kendo.stringify(options.models)};
}
}
},
batch: true,
pageSize: 4,
schema: {
model: {
id: 'ProductID',
fields: {
ProductID: { editable: false, nullable: true },
ProductName: 'ProductName',
UnitPrice: { type: 'number' },
Discontinued: { type: 'boolean' },
UnitsInStock: { type: 'number' }
}
}
}
});
attached() {
$(this.pager).kendoPager({
dataSource: this.dataSource
});
}
}
.product-view
{
float: left;
width: 50%;
height: 300px;
box-sizing: border-box;
border-top: 0;
position: relative;
}
.product-view:nth-child(even) {
border-left-width: 0;
}
.product-view dl
{
margin: 10px 10px 0;
padding: 0;
overflow: hidden;
}
.product-view dt, dd
{
margin: 0;
padding: 0;
width: 100%;
line-height: 24px;
font-size: 18px;
}
.product-view dt
{
font-size: 11px;
height: 16px;
line-height: 16px;
text-transform: uppercase;
opacity: 0.5;
}
.product-view dd
{
height: 46px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.product-view dd .k-widget,
.product-view dd .k-textbox {
font-size: 14px;
}
.k-listview
{
border-width: 1px 0 0;
padding: 0;
overflow: hidden;
min-height: 298px;
}
.edit-buttons
{
position: absolute;
bottom: 0;
left: 0;
right: 0;
text-align: right;
padding: 5px;
background-color: rgba(0,0,0,0.1);
}
.k-pager-wrap
{
border-top: 0;
}
span.k-invalid-msg
{
position: absolute;
margin-left: 6px;
}
.k-add-button {
margin-bottom: 2em;
}
@media only screen and (max-width : 620px) {
.product-view
{
width: 100%;
}
.product-view:nth-child(even) {
border-left-width: 1px;
}
}
<!doctype html>
<html>
<head>
<title>Aurelia KendoUI bridge</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.common.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.default.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.mobile.all.min.css">
<script src="https://kendo.cdn.telerik.com/2016.1.226/js/jszip.min.js"></script>
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script>
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-kendoui-bundles/0.3.5/config2.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-kendoui-bridge', kendo => kendo.pro());
aurelia.start().then(a => a.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment