I have this action result in a MVC 4 controller:
[ComboDataSourceAction] public ActionResult GetMyResult() { var _myResult = _wcfService.GetMyResult(); return View(_myResult.AsQueryable()); }
_myResult is just a List<MyItem>:
public sealed class MyItem { public int MyKey { get; set; }
public string MyDescription { get; set; } }
Then I have a view like this:
@using Infragistics.Web.Mvc
<div id="MyCombo"></div>
@(Html.Infragistics().Combo("MyCombo") .LoadOnDemandSettings(pLoad => pLoad.Enabled(true).PageSize(25)) .DataBind() .DataSource(@Url.Action("GetMyResult")) .DataSourceUrl(@Url.Action("GetMyResult")) .ValueKey("MyKey") .TextKey("MyDescription") .Width("300px") .Virtualization(true) .AutoComplete(true) .FilterExprUrlKey("startsWith") .FilteringType(ComboFilteringType.Remote) .RenderMatchItemsCondition(ComboRenderMatchItemsCondition.Contains) .Render())
When I run the application I get this error message:
Error: Unable to get property '__count' of undefined or null reference
The examples provided by Infragistics are related to OData and Json, I have tested it and runs fine, but I don't use that in my project, I use WCF to get my data into the controller then return a view with that data.
In the examples I see this thing:
responseDataKey: "d.results.Results",
responseTotalRecCountKey: "d.results.Count",
I understand that something similar is missed in my code but I don't know how to translate that when using Razor and my datasource.
By the way, I don't actually have a view related to the actionresult, the examples of Infragistics say you have to return a view but there are not any view source code for that in the examples, so I have no idea how that view is. Got it? ;) I just want to load on demand and reomotely the igcombo with data comming from a list converted to IQueryable or something the igcombo can manage. I use Infragistics Professional 2014 Vol. 1.
So, what's wrong with my code?
Hi Luis,
I am happy that you resolved the issue.
When LoadOnDemand is enabled on the igCombo, the control only requests the next set of data based on the settings. For example, if you have the PageSize set to 25, the request only pulls the next 25 records in the collection. I believe it is this reason that you are encountering the "very fast" behavior with the LoadOnDemand feature.
Hi Jose, this is embarrasing :( I changed my code to look like this and it worked beautifully:
@(Html.Infragistics().Combo("MyCombo") .LoadOnDemandSettings(pLoad => pLoad.Enabled(true).PageSize(25)) .DataBind() .DataSourceUrl(@Url.Action("GetMyResult")) .ValueKey("MyKey") .TextKey("MyDescription") .Width("300px") .FilteringType(ComboFilteringType.Remote) .Render())
Looks like DataSource doesn't share life with DataSourceUrl :) or maybe the other options. I have noticed that GetMyResult is called whenever the user types something, yet the query is very fast, caching in the server maybe?
I was lost because I followed the example provided by Infragistics and I mixed the source code for OData and MVC configuration, my fault.
Thank you Jose.
Thank you for posting on our forums.
The sample you are referring to uses a WebAPI service to retrieve the new data requested by the loadOnDemand feature for the igCombo.Links:http://www.igniteui.com/combo/load-on-demand http://help.infragistics.com/doc/jQuery/2014.1/CLR4.0/?page=igCombo_Load_on_Demand.html
At first glance, your logic appears to be fine. I believe this issue may be due to not setting the responseDataKey property as you've mentioned. Please note, the responseDataKey should consist of the key for the JSON data coming from your ViewModel. Note, this is specific to your data. Link:http://help.infragistics.com/Help/Doc/jQuery/2014.1/CLR4.0/html/igCombo_Configure_Remote_Filtering.html
I will be happy to create a sample that uses WCF to pass the data into the controller and return it as your ViewModel. I will post my sample to this thread once it's complete.
Please let me know if you have any questions regarding this matter.