DataSource Binding Not working

14 posts, 0 answers
  1. Eric
    Eric avatar
    57 posts
    Member since:
    Aug 2012

    Posted 05 Feb 2013 Link to this post

    Can someone please have a look at the code and screen shots below and see 
    if you can give me some idea why the grid is blank after returning a valid collection
    as part of a JsonResult?

    Html.Kendo().Grid<AppointmentsDTO>().Name("FailedAppointments")                 .Columns(columns =>                 {                     columns.Bound(o => o.MemberFirstName).Title("Member First").Width(80);                     columns.Bound(o => o.MemberLastName).Title("Member Last").Width(80);                     columns.Bound(o => o.ClientMemberID).Title("ClientID").Width(60);                     columns.Bound(o => o.ProviderID).Title("ProviderID").Width(60);                     columns.Bound(o => o.ProviderFirstName).Title("Provider First").Width(80);                     columns.Bound(o => o.ProviderLastName).Title("Provider Last").Width(100);                     columns.Bound(o => o.AppointmentDate).Title("Appointment Date").Width(200);                     columns.Bound(o => o.IHAAppointmentID).Hidden(true);                 })                 .EnableCustomBinding(true)                 .AutoBind(true)                 .Pageable(page => page.Enabled(true).PageSizes(new Int32[] {20, 30, 50,100}))                 .Sortable(sorting => sorting.SortMode(Kendo.Mvc.UI.GridSortMode.SingleColumn))                 .Selectable()                 .Scrollable(scroll => scroll.Height(350))                 .DataSource(dataSource => dataSource                     .Ajax()                     .Read(read => read.Action("BindFailedAppointments""AppointmentScheduling")))





  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 07 Feb 2013 Link to this post

    Hello,

    for testing purpose :  Can you please remove below selected property  and check it?



    If you have not added any key field then add it and check it.



    Let me know if any concern.

    Thanks,
    Jayesh Goyani
  3. Kendo UI is VS 2017 Ready
  4. Eric
    Eric avatar
    57 posts
    Member since:
    Aug 2012

    Posted 07 Feb 2013 Link to this post

    The problem is that the Ajax Action method must be decorated with either [HttpGet] or [HttpPost] depending on which Kendo scripts are referenced.

    The examples I seen here do not indicate that.
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 07 Feb 2013 Link to this post

    Hello Eric,

    A GET request will be used by default if the kendo.aspnetmvc.js file is not included. It contains the MVC transport which applies some default options so that the wrappers will work as expected with MVC controllers and the Server API. The file missing would also explain why the Grid is not populated - an exception will be thrown for returning JSON without specifying the JsonRequestBehavior to allow GET.
    The code that you shared looks correct. If this is not causing the problem, could you share a runnable sample so I can investigate further?

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Eric
    Eric avatar
    57 posts
    Member since:
    Aug 2012

    Posted 07 Feb 2013 Link to this post

    I fixed the problem by rearranging how the scripts are loaded and changing the verb to POST.

    Btw, my experience has been that if things are not registered in the right order, kendo.aspnetmvc.js will break the grid if you use GET.

    It's all very confusing in my opinion, and should be more clear in the examples. It seems to me that by providing this level a granularity in the script registeration process it causes more confusion than it helps. Developers who have already spent time learning Telerik MVC are not going to spend hours disecting hard to find documentation to find every little crack in the system.

    We were close to ditching Kendo in favor of the old controls because of this issue. In Agile we just do not have time to mess around if something is too time consuming.

    Thanks for the Help anyway...
  7. Xebra
    Xebra avatar
    5 posts
    Member since:
    Sep 2012

    Posted 07 Feb 2013 Link to this post

    Hi Eric,

    Would you mind posting the js includes (in order)? I cant get the grid to populate either. If I send it all through the view's model I can bind it just fine, but if I switch to AJAX it comes up blank.
  8. Eric
    Eric avatar
    57 posts
    Member since:
    Aug 2012

    Posted 08 Feb 2013 Link to this post

    <link href="@Url.Content("~/Content/AdminVisualIdentity.css")" rel="stylesheet" type="text/css" />     
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />         
    <
    link href="@Url.Content("~/Content/kendo.common.min.css")" rel="stylesheet" type="text/css" />     
    <
    link href="@Url.Content("~/Content/kendo.default.min.css")" rel="stylesheet" type="text/css" />     
    <link href="@Url.Content("~/Content/kendo.customblue.css")" rel="stylesheet" type="text/css" />     
    <script src="@Url.Content("~/Scripts/jquery/jquery-1.8.2.min.js")" type="text/javascript"></script>      
    <
    script src="@Url.Content("~/Scripts/jquery/json2.js")" type="text/javascript"></script>     
    <script src="@Url.Content("~/Scripts/jquery/jquery.corner.js")" type="text/javascript"></script>     
    <
    script src="@Url.Content("~/Scripts/jquery/jquery.maskedinput-1.3.min.js")" type="text/javascript"></script>     
    <script src="@Url.Content("~/Scripts/KendoUI/kendo.web.min.js")" type="text/javascript"></script>     
    <script src="@Url.Content("~/Scripts/KendoUI/kendo.aspnetmvc.min.js")" type="text/javascript"></script>      
    <script src="@Url.Content("~/Scripts/KendoUI/kendo.grid.min.js")" type="text/javascript"></script>  

    Use [HttpPost] on your Ajax method

    Type the grid to the class that comprises your list, my data is a List<AppointmentsDTO>
     @(Html.Kendo().Grid<AppointmentsDTO>()....

    Your DataSourceRequest object should have all the properties initialized,
    check by clicking a column and checking the Sorts collection.
  9. Xebra
    Xebra avatar
    5 posts
    Member since:
    Sep 2012

    Posted 08 Feb 2013 Link to this post

    Thanks for the info Eric!

    I walked back through the examples that you posted and discovered that my call to Entity Framework was returning type System.Data.Entity.DynamicProxies instead of the object type that I was specifying in the grid declaration. This seemed to be why the grid would not display the data.

    To test my theory, I explicitly turned off the 'entities.Configuration.ProxyCreationEnabled = false' and it then returned the object type that I specified in the grid and walla...the data appeared.
  10. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 08 Feb 2013 Link to this post

  11. Eric
    Eric avatar
    57 posts
    Member since:
    Aug 2012

    Posted 08 Feb 2013 Link to this post

    Yep. The easiest way to check is after .toDataSourceResult() you should see an IEnumerable collection of whatever type the grid is and that the Http verb is not being blocked on the Json result.
  12. Tyler
    Tyler avatar
    2 posts
    Member since:
    Jan 2013

    Posted 27 Feb 2013 Link to this post

    EDIT 3: I ended up using this to make it all work

    Q: why?
    DataSourceResult result = Kendo.Mvc.Extensions.QueryableExtensions.ToDataSourceResult(model,request);

    "It's all very confusing in my opinion, and should be more clear in the examples. It seems to me that by providing this level a granularity in the script registration process it causes more confusion than it helps. Developers who have already spent time learning Telerik MVC are not going to spend hours disecting hard to find documentation to find every little crack in the system."


    Today the Kendo UI Grid ate up 5 hours of my time trying to refactor something the client had already had built in Telerik. The documentation on Kendo sucks. My Grid is still broken and a whole application feature is broken because of it. I moved to Kendo because Telerik was so well documented it was easy to find a solution to almost any problem. 

    I am really regretting the move to Kendo.

    EDIT: 

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

    I mean really, come on, what kind of documentation is that, there is so many holes there. There is no depth, at least with the old telerik examples you included more descriptions, and included a model class as well. Really disappointing.

    EDIT 2:

    Additionally why don't you show the repository so we can at least reverse engineer what you have done. In your Examples your have a call to repository.All(). How am I supposed to know what is being returned from the repository? I am using entity framework, code first. DataSourceRequest what is that? Finally I want to state that I have searched every resource on Google and this site I could find while looking for an answer to this issue. 
  13. kevin
    kevin avatar
    2 posts
    Member since:
    May 2009

    Posted 26 Oct 2013 Link to this post

    I resolved my issue by this link.
    How do I avoid circular reference exceptions?
    http://docs.kendoui.com/documentation/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/faq#how-do-i-avoid-circular-reference-exceptions?
  14. Harshal
    Harshal avatar
    1 posts
    Member since:
    Sep 2016

    Posted 04 Oct in reply to Jayesh Goyani Link to this post

    same thing happening to my table . it is showing me the data for other table but not for one table.

     MasterDataModel obj = new MasterDataModel ();
                IEnumerable<MasterDataModel> entitlmentList = obj.GetEntitlementMasterRecords ();
                =>DataSourceResult result = entitlmentList.ToDataSourceResult(request);
                return Json (result, JsonRequestBehavior.AllowGet);

    the line to which arrow is pointing to not works the control goes smwhere else frm that point.It is not binding list data to data source

    please with any kind of soln u have...

  15. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 06 Oct Link to this post

    Hello,

    Is there an exception thrown by the ToDataSourceResult method? If yes, then could you provide the exception message? If no, then could you provide a runnable sample that demonstrates the problem?

    Regards,
    Daniel
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
Back to Top
Kendo UI is VS 2017 Ready