mirror of
https://github.com/hanzoai/jube-fork.git
synced 2026-11-02 09:25:40 +00:00
104 lines
4.1 KiB
HTML
Executable File
104 lines
4.1 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Custom validator editing</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 id="grid"></div>
|
|
|
|
<script>
|
|
$(document).ready(function () {
|
|
var crudServiceBaseUrl = "https://demos.telerik.com/kendo-ui/service",
|
|
dataSource = new kendo.data.DataSource({
|
|
transport: {
|
|
read: {
|
|
url: crudServiceBaseUrl + "/Products",
|
|
dataType: "jsonp"
|
|
},
|
|
update: {
|
|
url: crudServiceBaseUrl + "/Products/Update",
|
|
dataType: "jsonp"
|
|
},
|
|
destroy: {
|
|
url: crudServiceBaseUrl + "/Products/Destroy",
|
|
dataType: "jsonp"
|
|
},
|
|
create: {
|
|
url: crudServiceBaseUrl + "/Products/Create",
|
|
dataType: "jsonp"
|
|
},
|
|
parameterMap: function (options, operation) {
|
|
if (operation !== "read" && options.models) {
|
|
return { models: kendo.stringify(options.models) };
|
|
}
|
|
}
|
|
},
|
|
batch: true,
|
|
pageSize: 20,
|
|
schema: {
|
|
model: {
|
|
id: "ProductID",
|
|
fields: {
|
|
ProductID: { editable: false, nullable: true },
|
|
ProductName: {
|
|
validation: {
|
|
required: true,
|
|
productnamevalidation: function (input) {
|
|
if (input.is("[name='ProductName']") && input.val() != "") {
|
|
input.attr("data-productnamevalidation-msg", "Product Name should start with capital letter");
|
|
return /^[A-Z]/.test(input.val());
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
},
|
|
UnitPrice: { type: "number", validation: { required: true, min: 1} },
|
|
Discontinued: { type: "boolean" },
|
|
UnitsInStock: { type: "number", validation: { min: 0, required: true} }
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
$("#grid").kendoGrid({
|
|
dataSource: dataSource,
|
|
pageable: true,
|
|
height: 550,
|
|
toolbar: ["create"],
|
|
columns: [
|
|
"ProductName",
|
|
{ field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "120px" },
|
|
{ field: "UnitsInStock", title: "Units In Stock", width: "120px" },
|
|
{ field: "Discontinued", width: "120px" },
|
|
{ command: ["edit", "destroy"], title: " ", width: "250px"}],
|
|
editable: "inline"
|
|
});
|
|
});
|
|
</script>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|