Created
December 22, 2016 11:41
-
-
Save eliavmaman/82d16d440e12b08788bcb54ab11e8c8c to your computer and use it in GitHub Desktop.
Aurelia KendoUI component - problem report
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- put your view here --> | |
<template> | |
<require from="./grid"></require> | |
<button click.delegate="changeData()">Change different Data</button> | |
<grid view-model.ref="gridObj"></grid> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* put your view model code here */ | |
export class App { | |
constructor(){ | |
} | |
attached(){ | |
let data = [{ PlayersPlace: '123', From1To3: '234' }]; | |
this.gridObj.setData(data); | |
} | |
changeData(){ | |
let data =[{ PlayersPlace: '123', From2To4: '234',From5To6: '456' }]; | |
this.gridObj.setData(data); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<ak-grid k-widget.two-way="grid" | |
k-data-source.bind="dataSource" | |
k-sortable.bind="true" | |
k-selectable.bind="true" | |
k-navigatable.bind="true" | |
k-reorderable.bind="true"> | |
</ak-grid> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Grid { | |
constructor () { | |
this.dataSource = new kendo.data.DataSource({ | |
transport: { | |
read: (options) => { | |
if (options.data.data) { | |
options.success(options.data.data); | |
} else { | |
options.success([]); | |
} | |
} | |
}, | |
schema: { | |
model:this.model, | |
}, | |
pageSize: 15 | |
}); | |
} | |
setData(data) { | |
if (data) { | |
let gridData = data; | |
this.model = this.generateGrid(gridData ); | |
this.dataSource.read({ data: gridData}); | |
} | |
} | |
generateGrid(gridData) { | |
return this.generateModel(gridData[0]); | |
} | |
generateModel(gridData) { | |
this.model = {}; | |
this.model.id = "id"; | |
var fields = {}; | |
for (var property in gridData) { | |
var propType = typeof gridData[property]; | |
if (propType == "number") { | |
fields[property] = { | |
type: "number", | |
validation: { | |
required: true | |
} | |
}; | |
} else if (propType == "boolean") { | |
fields[property] = { | |
type: "boolean", | |
validation: { | |
required: true | |
} | |
}; | |
} else if (propType == "string") { | |
var parsedDate = kendo.parseDate(gridData[property]); | |
if (parsedDate) { | |
fields[property] = { | |
type: "date", | |
validation: { | |
required: true | |
} | |
}; | |
this.dateFields.push(property); | |
} else { | |
fields[property] = { | |
validation: { | |
required: true | |
} | |
}; | |
} | |
} else { | |
fields[property] = { | |
validation: { | |
required: true | |
} | |
}; | |
} | |
} | |
this.model.fields = fields; | |
return this.model; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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.2.714/styles/kendo.common.min.css"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.rtl.min.css"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.default.min.css"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.2.714/styles/kendo.mobile.all.min.css"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.4.0/bluebird.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.2.1/chroma.min.js"></script> | |
<script src="https://kendo.cdn.telerik.com/2016.2.714/js/jquery.min.js"></script> | |
<script src="https://kendo.cdn.telerik.com/2016.2.714/js/jszip.min.js"></script> | |
<script src="https://kendo.cdn.telerik.com/2016.2.714/js/kendo.all.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/1.0.0-beta.1.0.6/config2.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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