Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.38 KB | None | 0 0
  1. <div id="report-grid"></div>
  2. <script type="text/javascript">
  3.  
  4. $(function () {
  5. var productsDataSource = new kendo.data.DataSource({
  6. transport: {
  7. read: {
  8. url: "GridData",
  9. dataType: "json",
  10. contentType: 'application/json; charset=utf-8',
  11. type: 'GET',
  12. data: { param1: "val1", param2: "val2" } // ارسال اطلاعات اضافي و سفارشي به سرور در حين درخواست
  13. }
  14. },
  15. create: {
  16. url: "@Url.Action("PostProduct","Home")",
  17. contentType: 'application/json; charset=utf-8',
  18. type: "POST"
  19. },
  20. update: {
  21. url: function (TUser) {
  22.  
  23. return "@Url.Action("UpdateProduct","Home")/" + TUser.User_ID;
  24. },
  25. contentType: 'application/json; charset=utf-8',
  26. type: "PUT"
  27. },
  28. destroy: {
  29. url: function (product2) {
  30. return "@Url.Action("DeleteProduct","Home")/" + product.Id;
  31. },
  32. contentType: 'application/json; charset=utf-8',
  33. type: "DELETE"
  34. },
  35. parameterMap: function (options) {
  36. return kendo.stringify(options);
  37. },
  38. error: function (e) {
  39. alert(e.errorThrown.stack);
  40. },
  41. pageSize: 20,
  42. sort: { field: "Id", dir: "desc" },
  43. batch: false,
  44. });
  45.  
  46.  
  47.  
  48.  
  49. $("#report-grid").kendoGrid({
  50. dataSource: productsDataSource,
  51. autoBind: true,
  52. scrollable: false,
  53. //pageable: true,
  54. pageable: {
  55. previousNext: true, // default true
  56. numeric: true, // default true
  57. buttonCount: 5, // default 10
  58. refresh: true, // default false
  59. input: true, // default false
  60. //pageSizes: true, // default false
  61. pageSizes: [5, 10, 15, 20, 25,50,100], //array of page size choices for user
  62. info: true // show a label with current paging information in it
  63. },
  64. sortable: true,
  65. filterable: true,
  66. reorderable: true,
  67. columnMenu: true,
  68. groupable: true, // allows the user to alter what field the grid is grouped by
  69. editable: {
  70.  
  71. confirmation: "آيا مايل به حذف رديف انتخابي هستيد؟",
  72. destroy: true, // whether or not to delete item when button is clicked
  73. mode: "popup", // options are "incell", "inline", and "popup"
  74. //template: kendo.template($("#popupEditorTemplate").html()), // template to use for pop-up editing
  75. update: true, // switch item to edit mode when clicked?
  76. window: {
  77. title: "مشخصات محصول" // Localization for Edit in the popup window
  78. }
  79. },
  80.  
  81. columns: [
  82.  
  83. { field: "UserName", title: "شماره", width: "130px" },
  84. {
  85. field: "Name", title: "نام محصول",
  86. footerTemplate: "تعداد: #=count#"
  87. },
  88. {
  89. field: "Family", title: "نام محصول",
  90. footerTemplate: "تعداد: #=count#"
  91. },
  92. {
  93. command: [
  94. { name: "edit", text: "ويرايش" },
  95. { name: "destroy", text: "حذف" }
  96. ],
  97. title: "&nbsp;", width: "260px"
  98. }
  99. ],
  100.  
  101. toolbar: [
  102. { name: "create", text: "افزودن ردیف جدید" },
  103. { name: "save", text: "ذخیره‌ی تمامی تغییرات" },
  104. { name: "cancel", text: "لغو کلیه‌ی تغییرات" },
  105. { template: kendo.template($("#toolbarTemplate").html()) }
  106. ],
  107. messages: {
  108. editable: {
  109. cancelDelete: "لغو",
  110. confirmation: "آیا مایل به حذف این رکورد هستید؟",
  111. confirmDelete: "حذف"
  112. },
  113.  
  114. commands: {
  115. create: "افزودن ردیف جدید",
  116. cancel: "لغو کلیه‌ی تغییرات",
  117. save: "ذخیره‌ی تمامی تغییرات",
  118. destroy: "حذف",
  119. edit: "ویرایش",
  120. update: "ثبت",
  121. canceledit: "لغو"
  122. }
  123. }
  124. });
  125. });
  126. </script>
  127. <script>
  128. // اين اطلاعات براي تهيه خروجي سمت سرور مناسب هستند
  129. function getCurrentGridFilters() {
  130. var dataSource = $("#report-grid").data("kendoGrid").dataSource;
  131. var gridState = {
  132. page: dataSource.page(),
  133. pageSize: dataSource.pageSize(),
  134. sort: dataSource.sort(),
  135. group: dataSource.group(),
  136. filter: dataSource.filter()
  137. };
  138. return kendo.stringify(gridState);
  139. }
  140. </script>
  141.  
  142. <script id="toolbarTemplate" type="text/x-kendo-template">
  143. <a class="k-button" href="#" onclick="alert('gridState: ' + getCurrentGridFilters());">نوار ابزار سفارشي</a>
  144. </script>
  145.  
  146. <script type="text/x-kendo-template" id="priceTemplate">
  147. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement