This is a migrated thread and some comments may be shown as answers.

controller is not triggered...

5 Answers 295 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sylvain
Top achievements
Rank 1
Sylvain asked on 11 Oct 2012, 04:35 PM
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
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() { ... }
    }
The view
@{
    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

5 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 12 Oct 2012, 11:12 AM
Hi Sylvain,

Unfortunately, the provided information is not sufficient in order to track the cause for the issue you have described. Thus, could you please provide a small runnable sample in which this behavior can be observed locally.

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sylvain
Top achievements
Rank 1
answered on 12 Oct 2012, 12:35 PM
What do you need as a information ?

Creating another project will not help and provided my code for this project is not possible.
0
Sylvain
Top achievements
Rank 1
answered on 12 Oct 2012, 01:39 PM
Just for information, I created from scratch a asp.net mvc and create a grid with an Ajax datasource, it works.


I found (sorry in french) this error message : 
0x800a01b6 - Erreur d'exécution Microsoft JScript: L’objet ne gère pas la propriété ou la méthode « kendoGrid »

on the line :
jQuery(function(){jQuery("#Inventaire").kendoGrid({columns:[{title:"Id",field:"Id",encoded:true}],scrollable:false,dataSource:{transport:{read:{url:"/noolibee/Inventory/Inventory/InventoryObject/GetInventory"}},serverPaging:true,serverSorting:true,serverFiltering:true,serverGrouping:true,serverAggregates:true,type:"aspnetmvc-ajax",filter:[],error:onError,schema:{data:"Data",total:"Total",errors:"Errors",model:{fields:{Id:{type:"object"}}}}}});});

Its seems that jquery cannot find KendoGrid function
0
Accepted
Rosen
Telerik team
answered on 12 Oct 2012, 01:53 PM
Hi Sylvain,

You should verify that you have correctly setup the project to run KendoUI for ASP.NET MVC. Also please refer to this help article for most common causes for such error.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sylvain
Top achievements
Rank 1
answered on 12 Oct 2012, 02:07 PM
Ok .. it works ..

I had to remove my old telerik function
@(Html.Telerik().ScriptRegistrar())

Now I have to migrate all my site to kendo ;-(
Tags
Grid
Asked by
Sylvain
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Sylvain
Top achievements
Rank 1
Share this question
or