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

What should I put in Grid to have data bindings?

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 31 Jul 2013, 06:33 AM
Hello,
I'm almost at loading data from the api controller. I've got a controller that returns Json from a IEnumerable<Utenti> (POCO object)

I got this exception

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1502: The best overloaded method match for 'Kendo.Mvc.UI.Fluent.WidgetFactory.Grid(System.Data.DataTable)' has some invalid arguments

Source Error:

Line 7: <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
Line 8:
Line 9: <% Html.Kendo().Grid(Model)
Line 10: .Name("Grid")
Line 11: .AutoBind(true)


my aspx is

  <% Html.Kendo().Grid(Model) //
    .Name("Grid")
    .AutoBind(true)
    //.Columns(columns =>
    //{
    //    columns.Bound(x => x.IDUtente);
    //    columns.Bound(x => x.Nominativo);
    //    columns.Bound(x => x.Societa);
    //    columns.Bound(x => x.Filiale);
    //    columns.Bound(x => x.Ruolo);

    //    //columns.Bound(p => p.).Groupable(false);
    //    //columns.Bound(p => p.ProductName);
    //    //columns.Bound(p => p.UnitPrice);
    //    //columns.Bound(p => p.UnitsInStock);
    //})
        .Groupable()
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read =>
            {
                read.Action("GetListaUtenti", "Administration");
            })
        ).Render();
    %>

My controller is

 [HttpPost]
         public ActionResult GetListaUtenti([DataSourceRequest] DataSourceRequest request)
        {
         //   if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated) throw new SecurityExeption();

            DataAccessAdministration da = new DataAccessAdministration(Global.IDApplication, IDIstituto);

            int idUser = 185560;
            var res = da.GetListaUtenti(idUser);
            return Json(res);
        }

And the Utente item is of that type

 [DataContract]
    public class Utente
    {
        [DataMember]
        public int IDIstituto { get; set; }

        [DataMember]
        public int IDDipendente { get; set; }

        [DataMember]
        public string IDUtente { get; set; }

        [DataMember]
        public string Nominativo { get; set; }

        [DataMember]
        public string Filiale { get; set; }

        [DataMember]
        public string Societa { get; set; }

        [DataMember]
        public string Ruolo { get; set; }

        [DataMember]
        public string Profilo { get; set; }

        [DataMember]
        public string Funzioni { get; set; }

        [DataMember]
        public string Stato { get; set; }

        [DataMember]
        public int IDStato { get; set; }

        [DataMember]
        public int IDFunzione { get; set; }

        [DataMember]
        public int IDProfilo { get; set; }

        [DataMember]
        public Guid? SFGuid { get; set; }
    }

What should I put in the aspx in order to get data loaded?
Thanks

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 01 Aug 2013, 04:06 PM
Hello Paolo,

The provided Grid declaration indicates that server binding is used initially (see below) and the datasource configuration indicates that Ajax binding is used subsequently (when paging, sorting, etc).

Html.Kendo().Grid(Model)

The current problem is with the server binding. For more information about how to implement it, please refer to:

http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/server-binding

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Michele
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Share this question
or