jprusakova
jprusakova

Reputation: 1657

Telerik grid shows an empty column after delete command

I am using Telerik MVC Extensions Grid control, with AJAX binding, and run a delete command. Deletion works as intended, and the grid updates so that it doesn't show the deleted row.

However, after deleting one of the grid columns (the first one) shows up empty. There is also difference in the second column - 'false' instead of the unchecked box. Any ideas why, and how do I fix that?

I can refresh the screen, and that fixes the view. But it is a heavy page, and I'd rather not do the second refresh.

Delete first row:

After deleting, the first column shows up empty: Now first column is empty:

My grid:

Html.Telerik()
    .Grid(Model)
    .Name("scenarioGrid")
    .DataBinding(dataBinding => dataBinding.Ajax()
                                    .Delete("Delete", "Scenario"))
    .DataKeys(keys => keys.Add(c => c.Id))
    .Columns(columns =>
        {
            columns.Template(o => Html.ActionLink(o.Name, "Index", new {id = o.Name})).Title("Scenario")
                .FooterTemplate(@<text>Total @Model.Count() </text>);
            columns.Bound(o => o.IsLocked);
            columns.Bound(o => o.ContractMonth);
            columns.Bound(o => o.CreateDate);
            columns.Command(commands => commands.Delete().ButtonType(GridButtonType.Image)).Title("Delete");
        }
    )
    .Sortable()
    .Scrollable(scroll => scroll.Height(200))
    .ClientEvents(events => events.OnDelete("onDelete").OnComplete("afterDelete"))

Upvotes: 2

Views: 802

Answers (2)

Daniel
Daniel

Reputation: 5732

It looks like you are using server binding to load the grid, but ajax binding to update it. columns.Template is used for server binding. You should use ClientTemplate for ajax binding.

Upvotes: 1

Forty-Two
Forty-Two

Reputation: 7605

You shouldn't use columns.Template with Ajax binding. It's meant for server side bound grids. You should use

columns.Bound(o => 0.whatever).ClientTemplate("convert your link to a string here");

Upvotes: 1

Related Questions