This question is locked. New answers and comments are not allowed.
Hi,
I implemented a grid of towns (Villes) with inline editing. One of the fields contains dropdowns (server binding) of Regions from which is selected a region. In order to do so, the files ~/Views/DisplayTemplates/cbRegion.cshtml and ~/Views/EditingTemplates/cbRegion.cshtml were created and the model field was decorated with [UIHint("cbRegion"), Required].
There is no problem in edit mode since the dropdown is displayed nicelly.
The problem is in display mode where I get an error message from the DisplayTemplate file (cbRegion.cshtml) :
Line 2: @Model.nom <- error is here
The Grid definition is as below. Is there a setting or something else that I missed? Why is the model ok in edit mode (EditingTemplate file) and not in display mode? Is'nt the model passed the same way in both files?
Thanks
Grid definition:
I implemented a grid of towns (Villes) with inline editing. One of the fields contains dropdowns (server binding) of Regions from which is selected a region. In order to do so, the files ~/Views/DisplayTemplates/cbRegion.cshtml and ~/Views/EditingTemplates/cbRegion.cshtml were created and the model field was decorated with [UIHint("cbRegion"), Required].
There is no problem in edit mode since the dropdown is displayed nicelly.
The problem is in display mode where I get an error message from the DisplayTemplate file (cbRegion.cshtml) :
Object reference not set to an instance of an object.
Line 1: @model Phare.Models.RegionLine 2: @Model.nom <- error is here
The Grid definition is as below. Is there a setting or something else that I missed? Why is the model ok in edit mode (EditingTemplate file) and not in display mode? Is'nt the model passed the same way in both files?
Thanks
Grid definition:
@model IEnumerable<Phare.Models.Ville>@{ ViewBag.Title = "Villes";}<h2> Villes</h2>@(Html.Telerik().Grid(Model) .Name("Grid") .ToolBar(commands => commands.Insert()) .DataKeys(keys => keys.Add(c => c.ID)) .Columns(columns => { columns.Bound(o => o.ID); columns.Bound(o => o.nom); columns.Bound(o => o.Region); //Region is a complex type object for dropdown columns.Bound(o => o.description); columns.Command(commands => { commands.Edit(); commands.Delete(); }).Width(200); }) .DataBinding(dataBinding => dataBinding .Server() .Select("Index", "Ville") .Insert("Insert", "Ville") .Update("Save", "Ville") .Delete("Delete", "Ville")) .Scrollable(scrolling => scrolling.Enabled(true)) .Sortable(sorting => sorting.Enabled(true)) .Pageable(paging => paging.Enabled(true)) .Filterable(filtering => filtering.Enabled(true)) .Groupable(grouping => grouping.Enabled(false)) .Footer(true) .Editable(editing => editing.Mode(GridEditMode.InLine)))