Dear all,
I have a grid, with an ajax datasource, calling a function in my mvc controler. But the controler is never called by the grid.
What do I miss ?
Some informations:
Controler = InventoryOjbect (the controler is in an area, named Inventory)
Function = GetInventory
The URL : "http://localhost/noolibee/InventoryObject/GetInventory" works
I added an event "Error" on the datasource, but the event is never triggered also. For me, it's a problem for the datasource to find the controler and call the function .. but where is the problem !!
The model
The Controler
The view
Thanks for your help
I have a grid, with an ajax datasource, calling a function in my mvc controler. But the controler is never called by the grid.
What do I miss ?
Some informations:
Controler = InventoryOjbect (the controler is in an area, named Inventory)
Function = GetInventory
The URL : "http://localhost/noolibee/InventoryObject/GetInventory" works
I added an event "Error" on the datasource, but the event is never triggered also. For me, it's a problem for the datasource to find the controler and call the function .. but where is the problem !!
The model
public
class
InventoryObjectModel
{
public
InventoryObjectModel()
{
}
public
Guid Id {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
Guid PlaceId {
get
;
set
; }
public
Guid? ParentId {
get
;
set
; }
public
string
PlaceName {
get
;
set
; }
public
Guid CategoryId {
get
;
set
; }
public
string
CategoryName {
get
;
set
; }
public
string
Extra1 {
get
;
set
; }
public
string
Extra2 {
get
;
set
; }
public
string
Extra3 {
get
;
set
; }
public
string
TagSerial {
get
;
set
; }
public
Guid nodeId {
get
;
set
; }
public
string
NodeSerial {
get
;
set
; }
}
The Controler
public
class
InventoryObjectController : Controller
{
//
// GET: /Inventory/InventoryObject/
public
ActionResult Index()
{
return
View();
}
public
ActionResult GetInventory([DataSourceRequest] DataSourceRequest request)
{
var o = GetObjects();
DataSourceResult result = o.ToDataSourceResult(request);
return
Json(result, JsonRequestBehavior.AllowGet);
}
private
List<InventoryObjectModel> GetObjects() { ... }
}
@{
ViewBag.Title = "Inventory";
ViewBag.MainTitle = "Inventory";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<
div
>
@(Html.Kendo().Grid<
Noolibee.Presentation.Web.Administration.Areas.Inventory.Models.InventoryObjectModel
>()
.Name("Inventaire")
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.Id))
.Read(read => read.Action("GetInventory", "InventoryObject"))
.Events(events => events.Error("onError"))
)
)
</
div
>
<
script
>
function onError(e, status) {
if (e.errors) {
var message = "The following errors have occurred:\n";
$.each(e.errors, function (key, value) {
if (value.errors) {
message += value.errors;
}
});
alert(message);
}
}
</
script
>
Thanks for your help