This project is read-only.

Ajax problem

Sep 4, 2012 at 8:14 AM

Hi.

I have a grid that gets updated through an Ajax-request, but when the view is rendered I get the following error message:
"TypeError: GridMvc is not a constructor"
at gridmvc.js, line 14


Sep 4, 2012 at 9:19 AM

Could you provide your view code: how you update the grid and which browser you use.

Sep 5, 2012 at 7:55 AM
Edited Sep 5, 2012 at 7:56 AM

GridTest.cshtml:

@model IEnumerable<Car>

@using(Ajax.BeginForm("GridTestUpdate", new AjaxOptions { UpdateTargetId = "Grid" }))
{
	<input type="submit" value="Update" />
}

<div id="Grid">
	@{
		Html.RenderPartial("Grid", Model);
	}
</div>

Grid.cshtml:

@model IEnumerable<Car>

@Html.Grid(Model).Columns(columns => columns.Add(car => car.Name).Titled("Car"))

Controller:

public ActionResult GridTest()
{
List<Car> cars = new List<Car> {new Car {Name = "Volvo"}, new Car {Name = "Saab"}};
return(View(cars));
}

[HttpPost]
public PartialViewResult GridTestUpdate()
{
List<Car> cars = new List<Car> { new Car { Name = "Volvo" }, new Car { Name = "Saab" }, new Car {Name = "Mercedes"} };
return(PartialView("Grid", cars));
}

Tested in Firefox 15.0.

Sep 5, 2012 at 9:52 AM

It happens that I used the same variable names in js code. I have commit some changes for this issue.

Could you rename variable in _Grid.cshtml file:

was:

window.GridMvc = $("#grid-mvc").gridmvc();

need change to:

window.gridMvcControl = $("#grid-mvc").gridmvc();

Sep 5, 2012 at 11:32 AM

Yes, now it works.
Thanks!

May 26, 2015 at 3:08 PM
But it does not work so the pagination and filter, if I click on a page makes me a call back, and I GET overwrites the entire page.