or
@(Html.Kendo().DropDownListFor(model => model.EmailType) .Name("EmailType") .BindTo(Enum.GetNames(typeof (EmailTypeEnum)).ToList()) )When the popup is shown from an edit command, the value that is selected does not show in the grid after I click "Update". I can see the orange indicator that the fields is being edited in the grid, but the value is not shown.
If I do need to use a datasource object, can I use emuns as the underlying data type? If so please show an example.
Thanks
)
using System;using System.Collections.Generic;using System.Linq;using System.Web;namespace MCFD.MobilePolicy.MVC.Models{ public class SiteStructure { public SiteStructure() { } private List<string> next; private string myName = "N/A"; private List<InnerStructure> colHasChildren; private int ID; // Declare a Name property of type string: public string Name { get { return myName; } set { myName = value; } } public int id { get { return ID; } set { ID = value; } } //public bool HasChildren //{ // get // { // return hasChildren; // } // set // { // hasChildren = value; // } //} public List<InnerStructure> hasChildren { get { return colHasChildren; } set { colHasChildren = value; } } } public class InnerStructure { public InnerStructure() { } private List<string> next; private string myName = "N/A"; private List<InnerStructure> colHasChildren; private int ID; // Declare a Name property of type string: public string Name { get { return myName; } set { myName = value; } } public int id { get { return ID; } set { ID = value; } } //public bool HasChildren //{ // get // { // return hasChildren; // } // set // { // hasChildren = value; // } //} public List<InnerStructure> hasChildren { get { return colHasChildren; } set { colHasChildren = value; } } }}public JsonResult Employees(int? id) { //ulitimate goal is to transform this xml into a structure for the tree. I will deal with this later. Note that none of the bind to xml methods have worked for me. XElement xml = XElement.Load(Server.MapPath("~/App_Data/books.xml")); //Create 2 items for the tree Models.SiteStructure sitemapitem = new Models.SiteStructure(); sitemapitem.Name = "you"; sitemapitem.id = 1; Models.SiteStructure sitemapitem2 = new Models.SiteStructure(); sitemapitem2.Name = "me"; sitemapitem2.id = 2; //Create hierarchy by adding a new list to the first item in the root of items Models.InnerStructure sitemapitem3 = new Models.InnerStructure(); sitemapitem3.Name = "why does this not work?"; sitemapitem3.id = 3; List<Models.InnerStructure> sitemap2 = new List<Models.InnerStructure>(); sitemap2.Add(sitemapitem3); sitemapitem.hasChildren = sitemap2; //Add the items to list of items to return List<Models.SiteStructure> sitemap = new List<Models.SiteStructure>(); sitemap.Add(sitemapitem); sitemap.Add(sitemapitem2); return Json(sitemap, JsonRequestBehavior.AllowGet); }<div class="demo-section"> @(Html.Kendo().TreeView() .Name("treeview") .DataTextField("Name") .DataSource(dataSource => dataSource .Read(read => read .Action("Employees", "SiteEditor") ) ) ) </div>
@model IEnumerable<MyLibrary.Beamline>@{ ViewBag.Title = "Beamlines";}<h2>Beamlines</h2>@(Html.Kendo().Grid(Model) .Name("gvBeamlines") .Columns(columns => { columns.Command(command => { command.Edit(); }).Width(50); columns.Bound(o => o.Description).Width(100); columns.Bound(o => o.Insertion_Device).Title("Insertion Device"); columns.Bound(o => o.Status); columns.Bound(o => o.Energy_Range).Title("Energy Range"); columns.Command(command => { command.Destroy(); }).Width(50); }) .ToolBar(toolbar => toolbar.Create()) .Editable(editable => editable.Mode(GridEditMode.PopUp)) .Pageable() .Sortable() .DataSource(dataSource => dataSource .Server() .Model(model => model.Id(o => o.ID)) .Create(create => create.Action("Create", "Grid")) .Read(read => read.Action("Index", "Grid")) .Update(update => update.Action("Edit", "Grid")) .Destroy(destroy => destroy.Action("Delete", "Grid")) ) )using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using MyLibrary;namespace MyProject.Controllers{ public class BeamlinesController : Controller { // // GET: /Beamlines/ public ActionResult Index() { using (MyEntities context = new MyEntities()) { return View(context.Beamlines.ToList()); } } // // GET: /Beamlines/Details/5 public ActionResult Details(int id) { return View(); } // // GET: /Beamlines/Create public ActionResult Create() { return View(); } // // POST: /Beamlines/Create [HttpPost] public ActionResult Create(Beamline beamline) { try { // TODO: Add insert logic here return RedirectToAction("Index"); } catch { return View(); } } // // GET: /Beamlines/Edit/5 public ActionResult Edit(int id) { using (MyEntities context = new MyEntities()) { var beamline = context.Beamlines.Single(p => p.ID == id); return View(beamline); } } // // POST: /Beamlines/Edit/5 [HttpPost] public ActionResult Edit(int id, FormCollection collection) { using (MyEntities context = new MyEntities()) { var beamline = context.Beamlines.Single(p => p.ID == id); TryUpdateModel(beamline); if (ModelState.IsValid) { context.SaveChanges(); return RedirectToAction("Index"); } return View(beamline); } } // // GET: /Beamlines/Delete/5 public ActionResult Delete(int id) { return View(); } // // POST: /Beamlines/Delete/5 [HttpPost] public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here return RedirectToAction("Index"); } catch { return View(); } } }}