|
| 1 | +using Kendo.Mvc.UI; |
| 2 | +using pre_select_panelbar_item.Models; |
| 3 | +using System; |
| 4 | +using System.Collections.Generic; |
| 5 | +using System.Linq; |
| 6 | +using System.Web; |
| 7 | +using System.Web.Mvc; |
| 8 | + |
| 9 | +namespace PanelBarHierarchyBinding.Controllers |
| 10 | +{ |
| 11 | + public class HomeController : Controller |
| 12 | + { |
| 13 | + public ActionResult Index() |
| 14 | + { |
| 15 | + return View(); |
| 16 | + } |
| 17 | + |
| 18 | + public ActionResult LocalData() |
| 19 | + { |
| 20 | + ViewBag.ItemToSelect = "Second"; |
| 21 | + |
| 22 | + List<LocalPanelBarItem> pbItems = new List<LocalPanelBarItem>() { |
| 23 | + new LocalPanelBarItem |
| 24 | + { |
| 25 | + MenuName="First", |
| 26 | + MenuUrl = "firstUrl", |
| 27 | + ChildItems = new List<LocalPanelBarItem>() { |
| 28 | + new LocalPanelBarItem |
| 29 | + { |
| 30 | + MenuName="Child one of 1", |
| 31 | + MenuUrl = "thirdUrl", |
| 32 | + IsPreSelected = true |
| 33 | + }, |
| 34 | + new LocalPanelBarItem |
| 35 | + { |
| 36 | + MenuName="Child two of 1", |
| 37 | + MenuUrl = "fourthUrl" |
| 38 | + } |
| 39 | + } |
| 40 | + }, |
| 41 | + new LocalPanelBarItem |
| 42 | + { |
| 43 | + MenuName="Second", |
| 44 | + MenuUrl = "secondUrl" |
| 45 | + }, |
| 46 | + }; |
| 47 | + |
| 48 | + ViewBag.MyPanelBarItems = pbItems; |
| 49 | + |
| 50 | + return View(); |
| 51 | + } |
| 52 | + |
| 53 | + public ActionResult RemoteData() |
| 54 | + { |
| 55 | + ViewBag.ItemToSelect = "Second"; |
| 56 | + return View(); |
| 57 | + } |
| 58 | + |
| 59 | + public JsonResult ReadMenu(int? MenuId) |
| 60 | + { |
| 61 | + if (!MenuId.HasValue) |
| 62 | + { |
| 63 | + List<RemoteDataPanelBarItem> rootItems = new List<RemoteDataPanelBarItem>() { |
| 64 | + new RemoteDataPanelBarItem |
| 65 | + { |
| 66 | + MenuHasChild=true, |
| 67 | + MenuId=1, |
| 68 | + MenuName="First", |
| 69 | + MenuParentId=null, |
| 70 | + MenuUrl = "firstUrl" |
| 71 | + }, |
| 72 | + new RemoteDataPanelBarItem |
| 73 | + { |
| 74 | + MenuHasChild=false, |
| 75 | + MenuId=2, |
| 76 | + MenuName="Second", |
| 77 | + MenuParentId=null, |
| 78 | + MenuUrl = "secondUrl" |
| 79 | + }, |
| 80 | + }; |
| 81 | + |
| 82 | + return Json(rootItems, JsonRequestBehavior.AllowGet); |
| 83 | + |
| 84 | + } |
| 85 | + else |
| 86 | + { |
| 87 | + List<RemoteDataPanelBarItem> childItems = new List<RemoteDataPanelBarItem>() { |
| 88 | + new RemoteDataPanelBarItem |
| 89 | + { |
| 90 | + MenuHasChild=false, |
| 91 | + MenuId=3, |
| 92 | + MenuName="Child one of " + MenuId, |
| 93 | + MenuParentId=1, |
| 94 | + MenuUrl = "thirdUrl" |
| 95 | + }, |
| 96 | + new RemoteDataPanelBarItem |
| 97 | + { |
| 98 | + MenuHasChild=false, |
| 99 | + MenuId=4, |
| 100 | + MenuName="Child two of " + MenuId, |
| 101 | + MenuParentId=1, |
| 102 | + MenuUrl = "fourthUrl" |
| 103 | + } |
| 104 | + }; |
| 105 | + |
| 106 | + return Json(childItems, JsonRequestBehavior.AllowGet); |
| 107 | + } |
| 108 | + } |
| 109 | + |
| 110 | + } |
| 111 | +} |
0 commit comments