Advertisement
Guest User

Ada

a guest
Sep 21st, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.60 KB | None | 0 0
  1.  
  2. <div class="row" style="margin-bottom:10px;padding-left:10px;">
  3. <div class="col-md-1">
  4. Period:
  5. </div>
  6. <div class="col-md-8">
  7. <select id="ddlPeriod" onchange="ddlPeriod_onChange(this)"></select>
  8. </div>
  9. </div>
  10.  
  11. <div id="GridPane" style="height:100%">
  12. <div id="grid"></div>
  13.  
  14. @*@(Html.Kendo().Grid<CMS.Models.MsSqReconcile>()
  15. .Name("grid")
  16. .Scrollable()
  17. .Groupable()
  18. .Sortable()
  19. .Filterable(
  20. filterable => filterable.Extra(false)
  21. )
  22. .Resizable(resizeable => resizeable.Columns(true))
  23. .Pageable(pageable => pageable
  24. .Refresh(true)
  25. .PageSizes(true)
  26. .ButtonCount(5)
  27. )
  28. .Columns(
  29. columns =>
  30. {
  31. columns.Select().Width(35);
  32. columns.Bound(p => p.RowId).Title("Row Id").Hidden(true).Filterable(true);
  33. columns.Bound(p => p.Material).Title("Material");
  34. columns.Bound(p => p.Description).Title("Description");
  35. columns.Bound(p => p.MovAvgPrice).Title("Mov Avg Price");
  36. columns.Bound(p => p.TotalStock).Title("Total Stock");
  37. columns.Bound(p => p.TotalValue).Title("Total Value");
  38. columns.Bound(p => p.Status).Title("Status");
  39. columns.Bound(p => p.MainCount).Title("Main Count");
  40. columns.Bound(p => p.TagManual).Title("Tag Manual");
  41. columns.Bound(p => p.TotalQty).Title("Total Qty");
  42. columns.Bound(p => p.DiffMain).Title("Diff Main");
  43. columns.Bound(p => p.Amount).Title("Amount");
  44. }
  45. )
  46. .DataSource(dataSource => dataSource
  47. .Ajax()
  48. .Model(model => model.Id(p => p.Material))
  49. .Read(read => read.Action("ReconcileList", "Reconcile").Data("{period:\"}"))
  50. .PageSize(100)
  51. )
  52. .Events(m => m.Change("onChange"))
  53. .PersistSelection(true)
  54. .HtmlAttributes(new { style = "height: 400px" })
  55. )*@
  56.  
  57. </div>
  58. @*<button id="processTally" class="btn btn-success" style="margin-top:25px;">Add Reconcile</button>*@
  59. <style>
  60. #grid col, #grid td, #grid th {
  61. width: 150px;
  62. }
  63. </style>
  64.  
  65. <script>
  66. var period;
  67. var selectedIds = [];
  68.  
  69. $(document).ready(resizeGrid);
  70. $(window).resize(resizeGrid);
  71. $(document).ready(function () {
  72. InitCombo();
  73. $("#grid").kendoGrid({
  74. ///toolbar: ["excel"],
  75. toolbar: kendo.template($("#templateActBtn").html()),
  76. excel: {
  77. fileName: "Reconcile Data.xlsx",
  78. filterable: true
  79. },
  80. dataSource: {
  81. type: "aspnetmvc-ajax",
  82. transport: {
  83. read: "@Url.Content("~/Reconcile/ReconcileList/?period=")" + period
  84. },
  85. serverFiltering: true,
  86. serverPaging: true,
  87. serverSorting: true,
  88. pageSize: 100,
  89. schema: {
  90. data: "Data",
  91. total: "Total",
  92. errors: 'Errors',
  93. model: {
  94. id: "Material"
  95. }
  96. }
  97. },
  98. height: 460,
  99. groupable: true,
  100. sortable: true,
  101. pageable: {
  102. refresh: true,
  103. buttonCount: 5,
  104. pageSize: 50,
  105. pageSizes: [50, 100, 200, 500, 1000, 5000]
  106. },
  107. filterable: {
  108. extra: false
  109. //mode: 'row',
  110. //operators: {
  111. // string: {
  112. // contains: "contains"
  113. // }
  114. //}
  115. },
  116. change: onChange,
  117.  
  118. columns: [{
  119. selectable: true,
  120. width: 35
  121. }, {
  122. field: "RowId",
  123. title: "Row Id",
  124. hidden: true
  125. }, {
  126. field: "Material",
  127. title: "Material",
  128. }, {
  129. field: "Description",
  130. title: "Description"
  131. }
  132. , {
  133. field: "MovAvgPrice",
  134. title: "Mov Avg Price"
  135. }, {
  136. field: "TotalStock",
  137. title: "Total Stock"
  138. }, {
  139. field: "TotalValue",
  140. title: "Total Value"
  141. }, {
  142. field: "Status",
  143. title: "Status"
  144. }
  145. , {
  146. field: "Qty",
  147. title: "Main Count"
  148. }, {
  149. field: "QtyTagManual",
  150. title: "Tag Manual"
  151. }, {
  152. field: "TotalQty",
  153. title: "Total Qty"
  154. }, {
  155. field: "DiffMain",
  156. title: "Diff Main"
  157. }, {
  158. field: "Amount",
  159. title: "Amount"
  160. }
  161. ],
  162. persistSelection: true
  163. });
  164.  
  165. var grid = $("#grid").data("kendoGrid");
  166. var dropdown = grid.pager.element
  167. .find(".k-pager-sizes [data-role=dropdownlist]")
  168. .data("kendoDropDownList");
  169.  
  170. //var item = {};
  171.  
  172. //item[dropdown.options.dataTextField] = "50";
  173. //item[dropdown.options.dataValueField] = 50;
  174. //dropdown.dataSource.add(item);
  175. //item[dropdown.options.dataTextField] = "100";
  176. //item[dropdown.options.dataValueField] = 100;
  177. //dropdown.dataSource.add(item);
  178. //item[dropdown.options.dataTextField] = "200";
  179. //item[dropdown.options.dataValueField] = 200;
  180. //dropdown.dataSource.add(item);
  181. //item[dropdown.options.dataTextField] = "500";
  182. //item[dropdown.options.dataValueField] = 500;
  183. //dropdown.dataSource.add(item);
  184. //item[dropdown.options.dataTextField] = "1000";
  185. //item[dropdown.options.dataValueField] = 1000;
  186. //dropdown.dataSource.add(item);
  187. //item[dropdown.options.dataTextField] = "5000";
  188. //item[dropdown.options.dataValueField] = 5000;
  189. //dropdown.dataSource.add(item);
  190.  
  191. //dropdown.bind("change", function (e) {
  192. // if (this.text() == "All") {
  193. // grid.one("dataBound", function () {
  194. // setTimeout(function () {
  195. // dropdown.span.text("");
  196. // });
  197. // });
  198. // }
  199. // else if (this.text() == "50") {
  200. // grid.one("dataBound", function () {
  201. // setTimeout(function () {
  202. // dropdown.span.text("50");
  203. // });
  204. // });
  205. // }
  206. // else if (this.text() == "100") {
  207. // grid.one("dataBound", function () {
  208. // setTimeout(function () {
  209. // dropdown.span.text("100");
  210. // });
  211. // });
  212. // }
  213. // else if (this.text() == "200") {
  214. // grid.one("dataBound", function () {
  215. // setTimeout(function () {
  216. // dropdown.span.text("200");
  217. // });
  218. // });
  219. // }
  220. // else if (this.text() == "500") {
  221. // grid.one("dataBound", function () {
  222. // setTimeout(function () {
  223. // dropdown.span.text("500");
  224. // });
  225. // });
  226. // }
  227. // else if (this.text() == "1000") {
  228. // grid.one("dataBound", function () {
  229. // setTimeout(function () {
  230. // dropdown.span.text("1000");
  231. // });
  232. // });
  233. // }
  234. // else if (this.text() == "5000") {
  235. // grid.one("dataBound", function () {
  236. // setTimeout(function () {
  237. // dropdown.span.text("5000");
  238. // });
  239. // });
  240. // }
  241. //});
  242.  
  243. $('#processTally').click(function () {
  244. if (selectedIds.length > 0) {
  245. $.ajax({
  246. type: "POST", url: "@Url.Content("~/Reconcile/DoReconcile")",
  247. data: { data: selectedIds, period: $("#ddlPeriod").val()},
  248. success: function (resp) {
  249. if (JSON.stringify(resp) == "1") {
  250. kendo.alert('Succes add reconcile items');
  251. window.location.href = '@Url.Content("~/Reconcile")';
  252. } else {
  253. kendo.alert(resp);
  254. }
  255. }, failure: function (resp) {
  256.  
  257. }, error: function (resp) {
  258.  
  259. }
  260. });
  261. }
  262. else {
  263. alert("No selected items");
  264. }
  265. });
  266. });
  267.  
  268. function InitCombo() {
  269. $.ajax({
  270. type: "GET", url: "@Url.Content("~/Reconcile/GetPeriod")",
  271. success: function (resp) {
  272. var cd = resp;
  273. for (var field in cd.Period) {
  274. $('<option value="' + cd.Period[field] + '">' + cd.Period[field] + '</option>').appendTo('#ddlPeriod');
  275. }
  276. $("#ddlPeriod option:last").prop("selected", "selected");
  277. }, failure: function (resp) {
  278.  
  279. }, error: function (resp) {
  280.  
  281. }
  282. });
  283. }
  284. function ddlPeriod_onChange(obj) {
  285. period = $(obj).val();
  286. var grid = $("#grid").data("kendoGrid");
  287. var dataSource = new kendo.data.DataSource({
  288. type: "aspnetmvc-ajax",
  289. transport: {
  290. read: "@Url.Content("~//Reconcile/ReconcileList/?period=")" + period
  291. },
  292. serverFiltering: true,
  293. serverPaging: true,
  294. serverSorting: true,
  295. pageSize: 100,
  296. schema: {
  297. data: "Data",
  298. total: "Total",
  299. errors: 'Errors',
  300. model: {
  301. id: "Material"
  302. }
  303. }
  304. });
  305. grid.setDataSource(dataSource);
  306. }
  307. function onChange(arg) {
  308. var grid = $("#grid").data("kendoGrid");
  309. selectedIds = grid.selectedKeyNames();
  310. }
  311. function resizeGrid() {
  312. //Define Elements Needed
  313. var wrappersH = $(".content-wrapper");
  314. var header = $(".content-header");
  315. var content = $(".content");
  316. var grid = $("#grid");
  317.  
  318. //Other variables
  319. var minimumAcceptableGridHeight = 250; //This is roughly 5 rows
  320. var otherElementsHeight = 0;
  321.  
  322. //Get Window Height
  323. var windowHeight = $(window).outerHeight();
  324.  
  325. //Get Header Height if its existing
  326. var hasHeader = header.length;
  327. var headerHeight = hasHeader ? header.outerHeight(true) : 0;
  328.  
  329. //Get the Grid Element and Areas Inside It
  330. var contentArea = grid.find(".k-grid-content"); //This is the content Where Grid is located
  331. var otherGridElements = grid.children().not(".k-grid-content"); //This is anything ather than the Grid iteslf like header, commands, etc
  332. //console.debug(otherGridElements);
  333.  
  334. //Calcualte all Grid elements height
  335. otherGridElements.each(function () {
  336. otherElementsHeight += $(this).outerHeight(true);
  337. });
  338.  
  339. //Get other elements same level as Grid
  340. var parentDiv = grid.parent("div");
  341.  
  342. var hasMainContent = parentDiv.length;
  343. if (hasMainContent) {
  344. var otherSiblingElements = content.children()
  345. .not("#grid")
  346. .not("script");
  347.  
  348. //Calculate all Sibling element height
  349. otherSiblingElements.each(function () {
  350. otherElementsHeight += $(this).outerHeight(true);
  351. });
  352. }
  353.  
  354. //Padding you want to apply below your page
  355. var bottomPadding = 0;
  356.  
  357. //Check if Calculated height is below threshold
  358. var calculatedHeight = windowHeight - headerHeight - otherElementsHeight - bottomPadding;
  359. var finalHeight = calculatedHeight < minimumAcceptableGridHeight ? minimumAcceptableGridHeight : calculatedHeight;
  360.  
  361. var totalHeight = (wrappersH.outerHeight(true) - finalHeight) - 75;
  362.  
  363. //Apply the height for the content area
  364. contentArea.height(totalHeight);
  365. }
  366.  
  367. </script>
  368.  
  369. <script type="text/x-kendo-template" id="templateActBtn">
  370. <a id="processTally" class="btn btn-success" href="\\#">Add Recon</a>
  371. <a class="k-button k-button-icontext k-grid-excel pull-right" href="\\#"><span class="k-icon k-i-excel"></span>Export to Excel</a>
  372.  
  373. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement