When i set the property .Selectable() on a grid which is bound to a datamodel that has a parent model i get an error.
It looks like its trying to get the parent datamodel but it cant because the object context is closed.
here is my code
GeoAddress datamodel has a parent model 'Person' in the ef model.
the error i get is :
'The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.'
If i comment out these properties :
Then it works.
It looks like that setting selectable tries to call all model properties (and if one of those is lazy loading data from db error occurs).
I also have no problem on other models that do not have parent associations with other data models.
It looks like its trying to get the parent datamodel but it cant because the object context is closed.
here is my code
@
using
Kendo.Mvc.UI
@{
var addressList = Model.DataList
as
List<Intelli.Data.Parties.EFDAL.Entity.GeoAddress>;
}
@(Html.Kendo().Grid(addressList)
.Name(
"GridPartyGeoAddresses"
)
.Columns(columns =>
{
columns.Bound(p => p.ID).Title(
"ID"
).Hidden(
true
);
columns.Bound(p => p.Address).Title(
"Address"
).Width(160);
columns.Bound(p => p.Region).Title(
"Region"
).Width(80);
columns.Bound(p => p.Zipcode).Title(
"Zipcode"
).Width(80);
columns.Command(commands => commands
.Custom(
"btnviewgeoaddress"
)
.Text(
"View"
)
.Click(
"viewgeoaddress"
)
.HtmlAttributes(
new
{ style =
"text-align: center"
}));
columns.Command(commands => commands
.Custom(
"btndeletegeoaddress"
)
.Text(
"Remove"
)
.Click(
"deletegeoaddress"
)
.HtmlAttributes(
new
{ style =
"text-align: center"
}));
})
.Scrollable(scr => scr.Enabled(
true
).Height(300))
.Sortable(builder => builder.Enabled(
true
))
.Resizable(resizing => resizing.Columns(
true
))
.Selectable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(
false
)
)
)
GeoAddress datamodel has a parent model 'Person' in the ef model.
the error i get is :
'The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.'
If i comment out these properties :
.Selectable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(
false
)
)
Then it works.
It looks like that setting selectable tries to call all model properties (and if one of those is lazy loading data from db error occurs).
I also have no problem on other models that do not have parent associations with other data models.