Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. $(document).ready(function () {
  2. var crudServiceBaseUrl = "http://demos.telerik.com/kendo-ui/service",
  3. dataSource = new kendo.data.DataSource({
  4. transport: {
  5. read: {
  6. url: crudServiceBaseUrl + "/Products",
  7. dataType: "jsonp"
  8. },
  9. update: {
  10. url: crudServiceBaseUrl + "/Products/Update",
  11. dataType: "jsonp"
  12. },
  13. destroy: {
  14. url: crudServiceBaseUrl + "/Products/Destroy",
  15. dataType: "jsonp"
  16. },
  17. create: {
  18. url: crudServiceBaseUrl + "/Products/Create",
  19. dataType: "jsonp"
  20. },
  21. parameterMap: function (options, operation) {
  22. if (operation !== "read" && options.models) {
  23. return { models: kendo.stringify(options.models) };
  24. }
  25. }
  26. },
  27. batch: true,
  28. pageSize: 20,
  29. schema: {
  30. model: {
  31. id: "ProductID",
  32. fields: {
  33. ProductID: { editable: false, nullable: true },
  34. ProductName: {
  35. validation: {
  36. required: true,
  37. productnamevalidation: function (input) {
  38. if (input.is("[name='ProductName']") && input.val() != "") {
  39. input.attr("data-productnamevalidation-msg", "/^d{1,}$/");
  40. return /^d{1,}$/.test(input.val());
  41. }
  42.  
  43. return true;
  44. }
  45. }
  46. },
  47. UnitPrice: { type: "number", validation: { required: true, min: 1} },
  48. Discontinued: { type: "boolean" },
  49. UnitsInStock: { type: "number", validation: { min: 0, required: true} }
  50. }
  51. }
  52. }
  53. });
  54.  
  55. $("#grid").kendoGrid({
  56. dataSource: dataSource,
  57. pageable: true,
  58. height: 430,
  59. toolbar: ["create"],
  60. columns: [
  61. "ProductName",
  62. { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "100px" },
  63. { field: "UnitsInStock", title: "Units In Stock", width: "100px" },
  64. { field: "Discontinued", width: "100px" },
  65. { command: ["edit", "destroy"], title: " ", width: "172px"}],
  66. editable: "inline"
  67. });
  68. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement