Hi,
I have a grid inside a partial view that is bound to a local data (parent viewmodel is passed to the partial view).
The grid displays correctly the datas but when i try to edit a cell, i have this error: 'TypeError: Cannot read property 'Label' of undefined'.
Is there a way to solve this error?
Thanks;
6 Answers, 1 is accepted
Please make sure that IDs for the two grids are different. The id for a widget will be generated from the Name setting. Thus, ensure that the Name that is defined for the two grid is different and see how the behavior changes.
Regards,
Viktor Tachev
Progress Telerik
Hi Viktor,
Thanks for the reply.
In fact, i will only have one grid inside a partial view. I just wanted to show the different behaviour of the grid in edition.
I've attached a print screen of my code and the print screen of the page with only one grid.
In the index.cshtml i pass the model to the partial view. In the partial view, i may add or edit or delete rows and return the changes to the parent. The grid will be reused elsewhere.
Is-it something that can be done?
Thanks.
I checked the provided screencasts and based on them, I am not sure why the editing is causing this error.
Having said that, I created a test project, and it seems the partial view is working okay on my side. Could you please check and modify the attached project so it clearly replicates the issue?
I look forward to hearing from you.
Regards,
Preslav
Progress Telerik
Hi Preslav,
Thanks for the reply.
I've attached a print screen of the changes that replicates the issues.
Thanks.
Antonio
Thank you for elaborating on the scenario. I was able to replicate the problem. I need additional time to understand what is causing this behavior. Having said that, I will update this forum as soon as I get anything relating the issue.
In the meantime, as a workaround, you could the approach from my demo and pass the whole model to the partial view.
Regards,
Preslav
Progress Telerik
After an investigation it seems that this problem is rather with ASP.NET Core Editor razor helper. Same behavior can be replicated with the same setup and using the Html.EditorFor from ASP.NET Core.
public
class
HomePageModel
{
public
OrderViewModel Order {
get
;
set
; }
}
partial view:
@
using
Kendo.Mvc.UI;
@model TelerikAspNetCoreApp28.Models.OrderViewModel
@(Html.EditorFor(m => m.ShipName))
We logged an issue in the aspnet repository and we are waiting for a response.
In the meantime I would suggest either use the solution provided by my colleague Preslav Kozovski or change the editors from the Views/Shared/EditorTemplates folder to match the required data binding in order MVVM to work properly. For example the editor for string types should look like:
@model
object
@Html.Kendo().TextBox().Name(
"ShipName"
).HtmlAttributes(
new
{ data_bind =
"value:ShipName"
})
Regards,
Boyan Dimitrov
Progress Telerik