This is a migrated thread and some comments may be shown as answers.

Unable to bind to Title in editor Template

2 Answers 14 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 13 Dec 2018, 05:54 PM

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 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 17 Dec 2018, 01:28 PM
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.
0
Veselin Tsvetanov
Telerik team
answered on 17 Dec 2018, 01:29 PM
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.
Tags
Gantt
Asked by
Alex
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or