mirror of
https://github.com/hanzoai/jube-fork.git
synced 2026-11-03 01:01:41 +00:00
157 lines
4.7 KiB
HTML
Executable File
157 lines
4.7 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Drag & Drop</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" role="application">
|
|
<div class="demo-section k-content wide">
|
|
<img src="../content/web/listbox/arrow-left2right.png" alt="drag-indicator" class="arrow"/>
|
|
<br />
|
|
<select id="discontinued"></select>
|
|
<select id="available"></select>
|
|
<img src="../content/web/listbox/arrow-right2left.png" alt="drag-indicator" class="arrow"/>
|
|
<button id="save-changes-btn">Save changes</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
$(document).ready(function () {
|
|
var crudServiceBaseUrl = "https://demos.telerik.com/kendo-ui/service",
|
|
dataSource = new kendo.data.DataSource({
|
|
serverFiltering: false,
|
|
transport: {
|
|
read: {
|
|
url: crudServiceBaseUrl + "/Products",
|
|
dataType: "jsonp"
|
|
},
|
|
update: {
|
|
url: crudServiceBaseUrl + "/Products/Update",
|
|
dataType: "jsonp"
|
|
},
|
|
parameterMap: function (options, operation) {
|
|
if (operation !== "read" && options.models) {
|
|
return { models: kendo.stringify(options.models) };
|
|
}
|
|
}
|
|
},
|
|
requestStart: function () {
|
|
kendo.ui.progress($(".demo-section"), true);
|
|
},
|
|
requestEnd: function () {
|
|
kendo.ui.progress($(".demo-section"), false);
|
|
},
|
|
batch: false,
|
|
schema: {
|
|
model: {
|
|
id: "ProductID",
|
|
fields: {
|
|
ProductID: { editable: false, nullable: true },
|
|
Discontinued: { type: "boolean" },
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
dataSource.fetch(function () {
|
|
var data = this.data();
|
|
var discontinued = $("#discontinued").data("kendoListBox");
|
|
var available = $("#available").data("kendoListBox");
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
if (data[i].Discontinued) {
|
|
discontinued.add(data[i]);
|
|
}
|
|
else {
|
|
available.add(data[i]);
|
|
}
|
|
}
|
|
});
|
|
|
|
$("#discontinued").kendoListBox({
|
|
draggable: true,
|
|
connectWith: "available",
|
|
dropSources: ["available"],
|
|
dataTextField: "ProductName",
|
|
dataValueField: "ProductID",
|
|
remove: function (e) {
|
|
setDiscontinued(e, false);
|
|
},
|
|
add: function (e) {
|
|
setDiscontinued(e, true);
|
|
}
|
|
});
|
|
|
|
$("#available").kendoListBox({
|
|
draggable: true,
|
|
connectWith: "discontinued",
|
|
dropSources: ["discontinued"],
|
|
dataTextField: "ProductName",
|
|
dataValueField: "ProductID"
|
|
});
|
|
|
|
$("#save-changes-btn").kendoButton({
|
|
click: function (e) {
|
|
dataSource.sync();
|
|
}
|
|
});
|
|
|
|
function setDiscontinued(e, flag) {
|
|
var removedItems = e.dataItems;
|
|
for (var i = 0; i < removedItems.length; i++) {
|
|
var item = dataSource.get(removedItems[i].ProductID);
|
|
item.Discontinued = flag;
|
|
item.dirty = !item.dirty;
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style>
|
|
#example .k-listbox .k-item{
|
|
cursor: move;
|
|
}
|
|
|
|
#example .arrow {
|
|
padding: 8px 0 5px 238px;
|
|
}
|
|
|
|
#save-changes-btn {
|
|
float: right;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
#example .demo-section {
|
|
max-width: none;
|
|
width: 640px;
|
|
}
|
|
|
|
#example .k-listbox {
|
|
width: 275px;
|
|
height: 310px;
|
|
}
|
|
</style>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|