The control manages to bind and show the value from my model, but when I submit the form, the model in my controller does not show the updated value from the editor.
I have tried using a normal @Html.EditorFor() and this works as expected. (ie I see the updated value)
@model GeneralDisclosureEntity
@using (Html.BeginForm("GeneralDisclosureTextUpdate", "DataManagement", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div hidden="hidden">
@Html.EditorForModel()
</div>
@(Html.Kendo().EditorFor(m => m.HTML)
.Name("Content")
.HtmlAttributes(new { style = "width:100%;height:440px" })
.Encode(false)
.Tools(t => t.Clear()
.Bold()
.Italic()
.Underline()
.Strikethrough()
.JustifyLeft()
.JustifyCenter()
.JustifyRight()
.JustifyFull()
.InsertUnorderedList()
.InsertOrderedList()
.Indent()
.Outdent())
)
<br />
<button id="btnSubmit3" type="submit" style="float:right")>Save Text</button>
}
Hi There
I've been trying to get this right, and none of the demos or forums posts appear to really give me a clear answer.
I'm trying to populate a dropdownlist from a related table (Foreign Key), and I'm getting a "Value cannot be null" error.
Here's the scenario:
I have a Courses and Cities table, defined like this,
public class City { [Key] [ScaffoldColumn(false)] public int CityId { get; set; } [Required] [DisplayName("City Name")] public string CityName { get; set; } public virtual ICollection<Course> Courses { get; set; } }and this:
public class Course { [Key][ScaffoldColumn(false)] public int CourseId { get; set; } [Required] public string CourseName { get; set; } [ForeignKey("City")] [UIHint("GridForeignKey")] public int CityId { get; set; } public virtual City City { get; set; } [Required] [DisplayName("Course Rating")] [Range(0, 10)] public double CourseRating { get; set; } [Required] [DisplayName("Course Par")] public double CoursePar { get; set; } [DisplayName("Course Map Co-ords")] public string CourseMap { get; set; } [DisplayName("Course Notes")] public string CourseNotes { get; set; } public virtual ICollection<GolfRound> GolfRounds { get; set; } }So, clearly it's just a Golf Score app I'm using to help me learn.
I've scaffolded the Controller and Views using Kendo Scaffolder, and ended up with this:
public class CourseController : Controller { private GolfContext db = new GolfContext(); public ActionResult Index() { return View(); } public ActionResult Courses_Read([DataSourceRequest]DataSourceRequest request) { IQueryable<Course> courses = db.Courses; DataSourceResult result = courses.ToDataSourceResult(request, course => new { CourseId = course.CourseId, CourseName = course.CourseName, CourseRating = course.CourseRating, CoursePar = course.CoursePar, CourseMap = course.CourseMap, CourseNotes = course.CourseNotes }); return Json(result); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Courses_Create([DataSourceRequest]DataSourceRequest request, Course course) { if (ModelState.IsValid) { var entity = new Course { CourseName = course.CourseName, CourseRating = course.CourseRating, CoursePar = course.CoursePar, CourseMap = course.CourseMap, CourseNotes = course.CourseNotes }; db.Courses.Add(entity); db.SaveChanges(); course.CourseId = entity.CourseId; } return Json(new[] { course }.ToDataSourceResult(request, ModelState)); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Courses_Update([DataSourceRequest]DataSourceRequest request, Course course) { if (ModelState.IsValid) { var entity = new Course { CourseId = course.CourseId, CourseName = course.CourseName, CourseRating = course.CourseRating, CoursePar = course.CoursePar, CourseMap = course.CourseMap, CourseNotes = course.CourseNotes }; db.Courses.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return Json(new[] { course }.ToDataSourceResult(request, ModelState)); }
and for the View:
@(Html.Kendo().Grid<GolfScoreMVC.Models.Course>() .Name("grid") .Columns(columns => { columns.Bound(c => c.CourseName); columns.Bound(c => c.CourseRating); columns.Bound(c => c.CoursePar); columns.Bound(c => c.CourseMap); columns.Bound(c => c.CourseNotes); columns.ForeignKey(c => c.City, ( System.Collections.IEnumerable ) ViewData["Cities"], "CityId", "CityName"); columns.Command(command => { command.Edit(); command.Destroy(); }).Width(180); }) .ToolBar(toolbar => { toolbar.Create(); }) .Editable(editable => editable.Mode(GridEditMode.PopUp)) .Pageable() .Sortable(sortable => { sortable.SortMode(GridSortMode.SingleColumn); }) .Filterable() .Scrollable() .DataSource(dataSource => dataSource .Ajax() .Model(model => model.Id(p => p.CourseId)) .Read(read => read.Action("Courses_Read", "Course")) .Create(create => create.Action("Courses_Create", "Course")) .Update(update => update.Action("Courses_Update", "Course")) .Destroy(destroy => destroy.Action("Courses_Destroy", "Course")) ))Now, initially the CityId column was not scaffolded at all, but in the Create popup, I got a CityId input field.
I added the "columns.ForeignKey(c => c.City, ( System.Collections.IEnumerable ) ViewData["Cities"], "CityId", "CityName");" part to try and produce a dropdownlist, but I'm not getting it right.
I'm using the default GridForeignKey template template file, and when rendering this, is where the error comes in.
Please help me. The standard demo here confuses me even more.
Am I supposed to create a list of the Cities first, like this?
private GolfContext db = new GolfContext(); public ActionResult Index() { IList<City> myCities = db.Cities.ToList(); ViewData["Cities"] = myCities; return View(); }That doesn't work either. I'm clearly missing some obvious and simple step.
Regards
JohannS
I have a very basic model bound grid with edit and destroy commands.
When the grid is in Edit mode, I press the cancel button and I expect the row to stay the same as before, however the grid deletes the row? I have verified that it is not invoking any destroy methods
I have a problem with too small X button to close a modal window when my web site is viewed on tablet computers.
Using KendoUI with MVC. I have a window like this:
@(Html.Kendo().Window().Name("​mywindow").Title("​My very own Window Title text")
.Content("Loading...").Iframe(true).Width(600).Height(300).Visible(false).Modal(true)
)
What I want to do is make the title text and especially the X to close the window about 2x bigger to make it easier to use on tabled computers. I this possible? If so, how?
Hi.
Is it possible to open detail template for a grid in windows? not in child grid.
May be it is custom command for grid's row, but not sure in how do that.
How do you set focus for the Html.Kendo().MultiSelectFor in javascript?

How do you set focus to the Html.Kendo().DatePickerFor in javascript?

Is there any way to get the scheduler details after created the event.
Example: Once user created a event (Date: 08/17/2015 to 08/31/2015 Time: 9:00 AM to 10:AM, Repeat: Every 2 days), We want all days and times schedule is going to be generated.
Can you please advise and provide a sample project.