mirror of
https://github.com/hanzoai/jube-fork.git
synced 2026-11-02 14:29:36 +00:00
106 lines
3.4 KiB
HTML
Executable File
106 lines
3.4 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Add new item</title>
|
|
<meta charset="utf-8">
|
|
<link href="../content/shared/styles/examples-offline.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.common.min.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.rtl.min.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.default.min.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.default.mobile.min.css" rel="stylesheet">
|
|
<script src="../../js/jquery.min.js"></script>
|
|
<script src="../../js/jszip.min.js"></script>
|
|
<script src="../../js/kendo.all.min.js"></script>
|
|
<script src="../content/shared/js/console.js"></script>
|
|
<script>
|
|
|
|
</script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<a class="offline-button" href="../index.html">Back</a>
|
|
|
|
<div id="example">
|
|
<div class="demo-section k-content">
|
|
<h4>Type a custom product name</h4>
|
|
<input id="products" style="width: 100%;" />
|
|
<div class="demo-hint">e.g. 'custom'</div>
|
|
</div>
|
|
|
|
<script id="noDataTemplate" type="text/x-kendo-tmpl">
|
|
<div>
|
|
No data found. Do you want to add new item - '#: instance.filterInput.val() #' ?
|
|
</div>
|
|
<br />
|
|
<button class="k-button" onclick="addNew('#: instance.element[0].id #', '#: instance.filterInput.val() #')">Add new item</button>
|
|
</script>
|
|
|
|
<script>
|
|
function addNew(widgetId, value) {
|
|
var widget = $("#" + widgetId).getKendoDropDownList();
|
|
var dataSource = widget.dataSource;
|
|
|
|
if (confirm("Are you sure?")) {
|
|
dataSource.add({
|
|
ProductID: 0,
|
|
ProductName: value
|
|
});
|
|
|
|
dataSource.one("sync", function() {
|
|
widget.select(dataSource.view().length - 1);
|
|
});
|
|
|
|
dataSource.sync();
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
var crudServiceBaseUrl = "https://demos.telerik.com/kendo-ui/service";
|
|
var dataSource = new kendo.data.DataSource({
|
|
batch: true,
|
|
transport: {
|
|
read: {
|
|
url: crudServiceBaseUrl + "/Products",
|
|
dataType: "jsonp"
|
|
},
|
|
create: {
|
|
url: crudServiceBaseUrl + "/Products/Create",
|
|
dataType: "jsonp"
|
|
},
|
|
parameterMap: function(options, operation) {
|
|
if (operation !== "read" && options.models) {
|
|
return {models: kendo.stringify(options.models)};
|
|
}
|
|
}
|
|
},
|
|
schema: {
|
|
model: {
|
|
id: "ProductID",
|
|
fields: {
|
|
ProductID: { type: "number" },
|
|
ProductName: { type: "string" }
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
$("#products").kendoDropDownList({
|
|
filter: "startswith",
|
|
dataTextField: "ProductName",
|
|
dataValueField: "ProductID",
|
|
dataSource: dataSource,
|
|
noDataTemplate: $("#noDataTemplate").html()
|
|
});
|
|
});
|
|
</script>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|