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

ListView editable not working with complex objects

3 Answers 130 Views
ListView
This is a migrated thread and some comments may be shown as answers.
iCognition
Top achievements
Rank 1
Iron
iCognition asked on 27 Aug 2013, 04:50 AM
EditorTemplate:

<
div class="k-widget">
    @Html.HiddenFor(model => model.Id)
    <div class="edit-buttons">
        <a class="k-button k-button-icontext k-update-button" href="\\#"><span class="k-icon k-update"></span></a>
        <a class="k-button k-button-icontext k-cancel-button" href="\\#"><span class="k-icon k-cancel"></span></a>
    </div>
    <dl>
        <dt>
            @Html.LabelFor(model => model.SharedWith)
        </dt>
        <dd>
            @(Html.Kendo().MultiSelectFor(model => model.SharedWith)
                .DataValueField("Id")
                .DataTextField("Name")
                .Placeholder("Type user's name...")
                .DataSource(source =>
                {
                    source.Read(read =>
                    {
                        read.Action("Users", "User");
                    });
                })
                .TagTemplate("<div class=""tag-image""><img src=""#: Picture #"" height=""32"" /></div>")
                .ItemTemplate("<div class=""item-image""><img src=""#: Picture #"" height=""32"" /></div>"))
        </dd>
    </dl>
</div>
The list view display mode works fine, but as soon as I click edit, and it switches to the EditorTemplate, I get an error saying that Picture is undefined, even though the model that is being passed into the ListView constructor definitely has a fully populated SharedWith model.

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 28 Aug 2013, 05:17 PM
Hello Matt,

The template seems to be specified for the MultiSelect widget in the editor. Does the result from the Users action method contain a field name "Picture"?

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
iCognition
Top achievements
Rank 1
Iron
answered on 28 Aug 2013, 11:10 PM
Yes, it does.

The EditorTemplate works fine when it's called from a view, but when it's triggered by clicking edit from the ListView, javascript gives an error saying that Picture is not defined.
0
Daniel
Telerik team
answered on 30 Aug 2013, 02:38 PM
Hello again Matt,

Thank you for confirming. It seems that the problem occurs because the expression is used in a nested template and is not evaluated in the correct context. Please try to escape the "#" characters in the multiselect template and let me know if you still experience this problem:

.TagTemplate("<div class=""tag-image""><img src=""\\#: Picture \\#"" height=""32"" /></div>")
.ItemTemplate("<div class=""item-image""><img src=""\\#: Picture \\#"" height=""32"" /></div>"))
Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ListView
Asked by
iCognition
Top achievements
Rank 1
Iron
Answers by
Daniel
Telerik team
iCognition
Top achievements
Rank 1
Iron
Share this question
or