How can I change the fields that display for an Add/Update? For an add I need to have 4 fields display and for an edit I need to only display 2. I tried creating a template usercontrol but it is showing up for both an add/update. I tried modifying the viewmodel and that is applying the changes to both the add/update also.
Grid:
@(Html.Kendo().Grid(Model) .Name("CodeManager") .Columns(columns => { columns.Bound(p => p.CodeID); columns.Bound(p => p.Status); columns.Command(command => { command.Edit(); }).Width(200); }) .ToolBar(toolBar => toolBar.Create()) .Editable(editable => editable.Mode(GridEditMode.PopUp)) .Sortable() .Scrollable() .Groupable() .Pageable() .Filterable() .DataSource(dataSource => dataSource .Ajax() .Events(events => events.Error("error_handler")) .ServerOperation(false) .Model(model => { model.Id(p => p.CodeID); model.Field(p => p.CodeID).Editable(false); model.Field(p => p.Title).Editable(false); }) //.Read(read => read.Action("GetPersons", "CodeManager", new { classifications = @ViewBag.SelectedCatgory })) .Update(update => update.Action("EditingCustom_Update", "CodeManager")) .Create(update => update.Action("EditingCustom_Update", "CodeManager")) ) .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("_CodeEditor")) )Control:
public ActionResult Index(string classifications = "") { ViewData["Category"] = classifications; ViewData["Classifications"] = new SelectList(Classifications.List, "ClassificationText", "ClassificationText", classifications); var codModels = new List<CodeModel>(); ViewBag.SelectedCatgory = classifications ?? "Type"; if (Request.HttpMethod == "POST") { var model = _codeRepository.Search(classifications).ToModel(); return View(model); } return View(codModels); }Model:
blic class CodeModel { public string CodeID { get; set; } public string Title { get; set; } public string Status { get; set; } public bool Active { get; set; } public string Category { get; set; } public int UserID { get; set; } }
Thanks
Dennis