0

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

Oto Dušek
  • 61
  • 1
  • 11
  • I have tried to reproduce the issue, but it works for in my case. I can think of several reasons why it doesn't work: 1. Server rendering is turned on for the GridView or some of its parents. GridView render all its rows in HTML and cannot add new rows on postbacks while it is in server rendering mode. 2. There is some JavaScript error preventing the page to be updated - look in the Dev Tools Console tab. 3. The dataset has the page size of 4 - maybe the new items are just on another page. – Tomáš Herceg Sep 11 '18 at 07:51

1 Answers1

0

I was trying to use CoreUI boostrap template with DotVVM. But there is some javascript file which prevents DotVVM from updating the UI. In the console it shows some error.

Oto Dušek
  • 61
  • 1
  • 11