Pergunta

I'm having some trouble with callbacks on the MVC GridView control. When the page first loads everything looks good, but when I perform any action that requires a callback (for example, if I try to change pages) the action is performed successfully but then the loading animation appears over the grid and never goes away.

The weird thing here is that the actual callback functions nicely - if I change to page 2, the grid updates with page 2 and I can see all of the correct data, but the loading animation never goes away. If I change the sorting by clicking a heading, the new sort is applied and the grid refreshes but the loading animation still appears and doesn't go away.

My code follows (this is just a "messing around" learning exercise so please don't comment on code unrelated to the problem at hand).

View - Browse.cshtml

@model IEnumerable<VTData.Models.Client>

@{
    ViewBag.Title = "Browse";
}

<h1>Browse clients</h1>

@Html.Partial("BrowsePartial", Model)

View - BrowsePartial.cshtml

@model IEnumerable<VTData.Models.Client>

@Html.DevExpress().GridView(
    settings =>
    {
        settings.Name = "ClientGrid";
        settings.CallbackRouteValues = new {
            Controller = "Clients",
            Action = "ClientsPartial"
        };
        settings.KeyFieldName = "Id";
        settings.Columns.Add("Code");
        settings.Columns.Add("Given");
        settings.Columns.Add("Surname");
    }
).Bind(Model).GetHtml()

Controller

public class ClientsController : Controller
{
    //
    // GET: /Clients/
    public ActionResult Index()
    {
        var db = VTData.VTDatabase.Connect();
        var sql = PetaPoco.Sql.Builder.Select("*").From("client");

        return View("Browse", db.Query<Client>(sql));
    }

    public ActionResult ClientsPartial()
    {
        var db = VTData.VTDatabase.Connect();
        var sql = PetaPoco.Sql.Builder.Select("*").From("client");

        return PartialView("BrowsePartial", db.Query<Client>(sql));
    }
}

I can't figure out what's going wrong here. Any ideas?

Foi útil?

Solução

For anyone else who encounters this issue, it's dead simple and utterly embarrassing. The problem was that I hadn't included jQuery before including the DevExpress javascripts. Oops!

Outras dicas

I got a similar problem and resolved it. There was a null reference exception on server side, when the Dev express control was trying to load the data. Resolving that exception got my control working.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top