Advertisement
Guest User

derp

a guest
Jan 29th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5.03 KB | None | 0 0
  1. @using FDT.Excellence.Domain.Models
  2. @using FDT.Excellence.Resources.Helpers
  3. @using FDT.Excellence.Web.Helpers
  4.  
  5.  
  6.  
  7.  
  8.  
  9. @*@(Html.Kendo().TreeView()
  10.         .Name("Treeview")
  11.         .DragAndDrop(true)
  12.         .TemplateId("treeview-template")
  13.         .DataTextField("Name")
  14.             .DataSource(dataSource => dataSource
  15.                 .Model(m => m
  16.                         .Id("Id")
  17.                         .Children("Children")
  18.                         .HasChildren("HasChildren")
  19.                     )
  20.                     .Read(read => read.Action(MVC.ProductGroup.ProductGroup.ActionNames.ProductGroup2_Read, MVC.ProductGroup.ProductGroup.Name)
  21.                 )
  22.             )
  23.         .ExpandAll(true)
  24. )*@
  25. @*<button id="btn">qweqwe</button>*@
  26. <body>
  27.     <div id="treeview">
  28.  
  29.  
  30.         @*<script id="treeview-template" type="text/kendou-ui-template">
  31.                 <span id="name">#: item.Name#</span>
  32.                 <span>#: item.Number#</span>
  33.                 <span>#: item.IsActive#</span>
  34.                 <button><span class='k-icon k-edit' /></button>
  35.             </script>*@
  36.  
  37.         <script id="editTemplate" type="text/x-kendo-template">
  38.             <label>Text: <input class="k-textbox" value="#= node.Number #" /></label>
  39.             <button class="k-button k-primary">Save</button>
  40.         </script>
  41.  
  42.         <script>
  43.             var editTemlate = kendo.template($("treeview-template").html);
  44.             var jsonData = (function () {
  45.                 var json = null;
  46.                 $.ajax({
  47.                     'async': false,
  48.                     'global': false,
  49.                     'url': "http://localhost/FDT.Excellence.Web/ProductGroup/ProductGroup/ProductGroup2_Read",
  50.                     'dataType': "json",
  51.                     'success': function (data) {
  52.                         json = data;
  53.                     }
  54.                 });
  55.                 return json;
  56.             })();
  57.             console.log(jsonData);
  58.  
  59.             // only async
  60.             //$.getJSON('http://localhost/FDT.Excellence.Web/ProductGroup/ProductGroup/ProductGroup2_Read', function (data) {
  61.             //    //console.log(data);
  62.             //}); // close getJSON
  63.  
  64.            
  65.             var dataSource = new kendo.data.HierarchicalDataSource({
  66.                 data: jsonData,
  67.                 schema: {
  68.                     model: {
  69.                         hasChildren: "HasChildren",
  70.                         children: "Children"
  71.                     }
  72.                 }
  73.             });
  74.  
  75.             var editTemplate = kendo.template($("#editTemplate").html());
  76.  
  77.             var treeview = $("#treeview").kendoTreeView({
  78.                 dragAndDrop: true,
  79.                 dataSource: dataSource,
  80.                 template: "<span>#: item.Name#</span> <span>#: item.Number#</span> <span>#: item.IsActive#</span><button><span class='k-icon k-edit' /></button>"
  81.             })
  82.             .on("click", "button", function (e) {
  83.  
  84.                 e.preventDefault();
  85.                 var node = $("#treeview").getKendoTreeView().dataItem(e.currentTarget);
  86.                 $("<div />")
  87.                 .html(editTemplate({ node: node }))
  88.                 .appendTo("body")
  89.                 .kendoWindow({
  90.                     modal: true,
  91.                     visible: false,
  92.                     deactivate: function () {
  93.                         this.destroy();
  94.                     }
  95.                 })
  96.                 .on("click", ".k-primary", function (e) {
  97.                     e.preventDefault();
  98.  
  99.                     var dialog = $(e.currentTarget).closest("[data-role=window]").getKendoWindow();
  100.                     var textbox = dialog.element.find(".k-textbox");
  101.  
  102.                     console.log("Textbox värdet: "+textbox.val());
  103.                     node.set("Number", textbox.val());
  104.                     console.log("Uppdaterad textbox: " + textbox.val());
  105.                     jsonData.
  106.                     dialog.close();
  107.                 })
  108.                 .getKendoWindow().center().open();
  109.             }); // on(click,button)
  110.  
  111.         </script>
  112.  
  113.     </div>
  114. </body>
  115.  
  116.  
  117.  
  118. @*<div id="treelist" />
  119.  
  120.     <script>
  121.         var dataSource = new kendo.data.TreeListDataSource({
  122.             data: [{ name: "namn1" }, { name: "namn2" }]
  123.         });
  124.  
  125.         $("#treelist").kendoTreeList({
  126.             columns: [{ field: "name", title: "Name" }, { field: "blabla", title: "BLABLA" }],
  127.             editable: {mode:"inline"},
  128.             dataSource: dataSource
  129.         });
  130.  
  131.     </script>*@
  132.  
  133.  
  134.  
  135. @*@(Html.Kendo().Window()
  136.         .Name("BCDetailsDialog")
  137.             .Title(this.GetString(ResourceHelper.GetResource(ResourceBusinessContactKey.ListViewDetailsWindow)))
  138.             .Content(this.GetHtmlString(ResourceHelper.GetResource(ResourceBusinessContactKey.ListViewDetailsWindowLoading)).ToString())
  139.         .Visible(false)
  140.         .Draggable()
  141.                 .Events(e => e.Refresh("BusinessContacts.InitializeKendoDialog"))
  142.     )*@
  143.  
  144. @section Scripts {
  145.     @Scripts.Render("~/Scripts/Pages/BusinessContacts.js");
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement