Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function () {
- var crudServiceBaseUrl = "http://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", "/^d{1,}$/");
- return /^d{1,}$/.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: 430,
- toolbar: ["create"],
- columns: [
- "ProductName",
- { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "100px" },
- { field: "UnitsInStock", title: "Units In Stock", width: "100px" },
- { field: "Discontinued", width: "100px" },
- { command: ["edit", "destroy"], title: " ", width: "172px"}],
- editable: "inline"
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement