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

DataSource Binding Not working

13 Answers 1998 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 05 Feb 2013, 10:04 PM
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")))





13 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 07 Feb 2013, 02:03 PM
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
0
Eric
Top achievements
Rank 1
answered on 07 Feb 2013, 03:47 PM
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.
0
Daniel
Telerik team
answered on 07 Feb 2013, 10:08 PM
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!
0
Eric
Top achievements
Rank 1
answered on 07 Feb 2013, 10:19 PM
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...
0
Xebra
Top achievements
Rank 1
answered on 08 Feb 2013, 03:33 AM
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.
0
Eric
Top achievements
Rank 1
answered on 08 Feb 2013, 01:09 PM
<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.
0
Xebra
Top achievements
Rank 1
answered on 08 Feb 2013, 04:34 PM
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.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 08 Feb 2013, 04:39 PM
0
Eric
Top achievements
Rank 1
answered on 08 Feb 2013, 04:41 PM
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.
0
Tyler
Top achievements
Rank 1
answered on 27 Feb 2013, 06:07 PM
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. 
0
kevin
Top achievements
Rank 2
answered on 26 Oct 2013, 07:20 PM
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?
0
Harshal
Top achievements
Rank 1
answered on 04 Oct 2016, 10:45 AM

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...

0
Daniel
Telerik team
answered on 06 Oct 2016, 07:53 AM
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.
 
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Eric
Top achievements
Rank 1
Daniel
Telerik team
Xebra
Top achievements
Rank 1
Tyler
Top achievements
Rank 1
kevin
Top achievements
Rank 2
Harshal
Top achievements
Rank 1
Share this question
or