This question is locked. New answers and comments are not allowed.
Hi There,
I want to stop the Grid view 'edit' command to evaluating the foreign key properties on editable mode. The one bellow is a sample code of what I'm doing in my custom ORM.
The view for the gird view is follows:
I don't want the editor not only just to display the field but also not to evaluate the property. The exception get thrown all the time hence the grid view control access the 'Collection' property of the 'Instrument' model. This happens when I enable editing (i.e. commands.Edit(); ) on read-only grid view the property doesn't get accessed if not bound. Can you please suggest me a way to attribute or anything similar to not to access the property.
It is very crucial on an EntityFramework since the lazy loading Foreign Entities will get loaded from the database unnecessarily.
FYI: The Html.EditForModel(); works fine for the same Entity class
Thanks in advance
I want to stop the Grid view 'edit' command to evaluating the foreign key properties on editable mode. The one bellow is a sample code of what I'm doing in my custom ORM.
public partial class Instrument{ public int Id { get; set; } public string CodeBbg { get; set; } public string Name { get; set; } public string InstrumentType { get; set; } public DateTime Created { get; set; } [ScaffoldColumn(false)] public string Description { get; set; } private ICollection<int> _collection; [ScaffoldColumn(false)] public virtual ICollection<int> Collection { get { throw new Exception("The collection is not populated yet"); } set { _collection = value; } } private string _notes; [ScaffoldColumn(false)] public string Notes { get { throw new Exception("The collection is not populated yet"); } set { _notes = value; } }}The view for the gird view is follows:
@model IEnumerable<TelerikMvcGridTest.Models.Instrument>@(Html.Telerik().Grid(Model) .DataKeys(keys => keys.Add(i => i.Id)) .Name("Grid") .Columns(columns => { columns.Bound(instrument => instrument.Id).Width(100); columns.Bound(instrument => instrument.CodeBbg).Width(200); columns.Bound(instrument => instrument.Name); columns.Bound(instrument => instrument.InstrumentType).Width(120); columns.Command(commands => { commands.Edit(); }).Width(200); }) .Groupable() .DataBinding(dataBinding => dataBinding.Ajax() .Update("Update", "Index")) .Editable(editing => editing.Mode(GridEditMode.PopUp)) .Sortable() .Pageable() .Filterable())I don't want the editor not only just to display the field but also not to evaluate the property. The exception get thrown all the time hence the grid view control access the 'Collection' property of the 'Instrument' model. This happens when I enable editing (i.e. commands.Edit(); ) on read-only grid view the property doesn't get accessed if not bound. Can you please suggest me a way to attribute or anything similar to not to access the property.
It is very crucial on an EntityFramework since the lazy loading Foreign Entities will get loaded from the database unnecessarily.
FYI: The Html.EditForModel(); works fine for the same Entity class
@using (Html.BeginForm()){ @Html.EditorForModel();}Thanks in advance