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

Popup Editor with Editor widget not updating model field

4 Answers 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cool Breeze
Top achievements
Rank 1
Cool Breeze asked on 22 Mar 2014, 07:07 AM
Hello,

I have a grid which is using a popup editor form, so I have a shared view serving as the popup form. Inside that shared view I am editing a string field by using:

@Html.EditorFor( zone=> zone.ZoneContents, "ContentEditor", new { contents = Model.ZoneContents})

So this is using my "ContentEditor" shared view which is under the Views/Shared/EditorTemplates folder. All is well and good. The editor appears, I'm able to insert content and then when I try to update I get an error because zone.zonecontents is null.

Why would it not be updating the model with the value?

I would have posted some more code in here but the formatter isn't currently working and it would be pretty ugly. I can post more later, just let me know what you want to see.

Thanks!

4 Answers, 1 is accepted

Sort by
0
Cool Breeze
Top achievements
Rank 1
answered on 22 Mar 2014, 07:10 AM
Here is my editor partial view:


@model string
 
    @(Html.Kendo().EditorFor(zoneContent => zoneContent)
    .Name("ContentEditor")
    .HtmlAttributes(new { style = "width:740px;height:440px"})
    .Tools(tools => tools
        .Clear()
        .Bold().Italic().Underline().Strikethrough()
        .JustifyLeft().JustifyCenter().JustifyRight().JustifyFull()
        .InsertUnorderedList().InsertOrderedList()
        .Outdent().Indent()
        .CreateLink().Unlink()
        .InsertImage()
        .SubScript()
        .SuperScript()
        .TableEditing()
        .ViewHtml()
        .Formatting()
        .FontName()
        .FontSize()
        .FontColor().BackColor()
      )
            .ImageBrowser(imageBrowser => imageBrowser
                .Image("~/Images/ZoneImages/{0}")
                .Read("Read", "ImageBrowser")
                .Create("Create", "ImageBrowser")
                .Destroy("Destroy", "ImageBrowser")
                .Upload("Upload", "ImageBrowser")
                .Thumbnail("Thumbnail", "ImageBrowser"))
              .Render()
      )
0
Cool Breeze
Top achievements
Rank 1
answered on 22 Mar 2014, 01:59 PM
If I take out the .Name("ContentEditor") line the value does get passed through. Why?
0
Accepted
Vladimir Iliev
Telerik team
answered on 25 Mar 2014, 11:35 AM
Hi Joe,

Please note that when you are using the EditorFor the "Name" option is automatically set to the name of the related field. This configuration option should not be overridden as it's used by the Grid to find the correct editor for given field in the model (the "id" attribute of the editor should match the name of the edited field).

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Cool Breeze
Top achievements
Rank 1
answered on 25 Mar 2014, 06:08 PM
I figured as much when it dawned on me that I was using "EditorFor". Thank you!
Tags
Grid
Asked by
Cool Breeze
Top achievements
Rank 1
Answers by
Cool Breeze
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or