I have a problem with binding GridView in DotVVM. I load data from EF Core and fill the GridViewDataSet property and bind the property to GridView. Below the GridView I have form for adding new rows to a table. When I load page it does bind correctly. It shows all rows it should, but when I add new row using form, it does not refresh data in the GridView. Postback is invoked, I see it in Developer Tools in chrome. It even send correctly viewModelDiff, but it does not refresh UI. What am I missing?
dothtml:
<dot:GridView DataSource="{value: Stables}" class="table table-responsive-sm table-sm" ShowHeaderWhenNoData="true">
<Columns>
<dot:GridViewTextColumn ValueBinding="{value: Id}" HeaderText="ID" />
<dot:GridViewTextColumn ValueBinding="{value: Name}" HeaderText="Name" />
</Columns>
</dot:GridView>
ViewModel:
public GridViewDataSet<Stable> Stables { get; set; } = new GridViewDataSet<Stable>() { PagingOptions = { PageSize = 4 } };
public override Task PreRender()
{
LoadStables();
return base.PreRender();
}
public void LoadStables()
{
if (Stables.IsRefreshRequired)
{
Stables.LoadFromQueryable(_ctx.Stables);
}
}
public void AddStable()
{
_ctx.Stables.Add(new Stable()
{
Id = StableId,
Name = StableName
});
_ctx.SaveChanges();
Stables.RequestRefresh();
}
I am using DotVVM.AspNetCore 2.0.2