Unable to bind to Title in editor Template

3 posts, 0 answers
  1. Alex
    Alex avatar
    76 posts
    Member since:
    May 2015

    Posted 13 Dec 2018 Link to this post

    Portion of my gantt chart code:

        @(Html.Kendo()
            .Gantt<ProjectMilestoneGanttTaskViewModel, ProjectMilestoneGanttDependencyViewModel>()
            .Name(ganttName)
            .Editable(e =>
            {
                e.DragPercentComplete(false);
                e.Template(Html.Partial("EditorTemplates/ProjectMilestoneGanttTaskViewModel", new ProjectMilestoneGanttTaskViewModel()).ToHtmlString());
            })     

     

    ProjectMilestoneGanttTaskViewModel.cshtml:

    @model ProjectMilestoneGanttTaskViewModel
     
    @Html.EditorFor(x => x.Title)

     

    Title will not bind in the editor template, it always appears blank. I have plenty of other fields that are not "Title", and those bind perfectly. If I change the name it also binds just fine. I noticed that in the your editor template in the demo it uses lower case "title". I would simply use another name than title but IGanttTask is expecting a "Title" field.

    Is this a known issue?

     

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1241 posts

    Posted 17 Dec 2018 Link to this post

    Hello Alex,

    The default EditorFor() would not allow you to pass the appropriate attributes that would bind the initial value for the Title field properly. Therefore, I would suggest you to use the Telerik TextBoxFor() HTML helper instead:
    @Html.Kendo().TextBoxFor(x => x.Title).HtmlAttributes(new { data_bind = "value: title" })

    Attached you will find a small sample, based on the snippets sent, which implements the above suggestion.

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1241 posts

    Posted 17 Dec 2018 Link to this post

    Hello Alex,

    Attached is the sample project.

    Regards,
    Veselin Tsvetanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top