I am trying to evaluate this product to see if we want to use it in our project but am getting and error on the grid.
JavaScript runtime error: Unable to get property 'length' of undefined or null reference
My grid code is
@(Html.Infragistics().Grid<MvcTestAuthData.Models.Users>()
.DataSourceUrl(Url.Action("UsersList")).ResponseDataKey("") .ID("userList").Width("650px").Height("280px") .LoadOnDemand(false) .AutoGenerateColumns(false) .Columns(column => { column.For(x => x.Username).HeaderText("User Name").DataType("string"); column.For(x => x.Password).HeaderText("Password").DataType("string"); }) .Features(features => { features.Paging().Type(OpType.Local).VisiblePageCount(5).ShowPageSizeDropDown(true).PageSize(10).PrevPageLabelText("Previous").NextPageLabelText("Next"); features.Sorting().Mode(SortingMode.Single).ColumnSettings(settings => { settings.ColumnSetting().ColumnKey("UserName").AllowSorting(true);
}); features.Selection().MouseDragSelect(true).MultipleSelection(false).Mode(SelectionMode.Row); }) .Width("650") .DataBind() .Render() )
the data source is a function in the controller and returns a Ilist of the model class MvcTestAuthData.Models.Users
[GridDataSourceAction]
public ActionResult UsersList() { var service = new UsersService(); var users = service.GetUsers(); return View(users); }
I'm not sure if i am even binding the data correctly. Using Jquery 1.7.1 and the downloaded IgniteUI 2012 Vol 2 monday so what ever version that was.
thank you
Hello David,
Currently our igGrid requires data source of type IQueryable, therefore please make sure that you provide this kind of data source in the GridDataSourceAction:
users.AsQueryable();
For additional reference how you can bind the igGrid you can take a look at the following link from our documentation:
http://help.infragistics.com/NetAdvantage/jQuery/2012.2/CLR4.0?page=igGrid_Developing_ASP_NET_MVC_Applications_with_igGrid.html
Please let me know if this helps.
Hi,
Thank you for your response. Changing my controller code eliminated the lenght error but now i get the error
Unhandled exception at line 25, column 77307 in http://localhost:49553/Scripts/Infragistics/js/modules/infragistics.ui.grid.framework.js
0x800a139e - JavaScript runtime error: The remote request to fetch data has failed: (error) undefined.
I have put a break in my controller code and it is returning data but the grid is failing
Feel free to contact me if you need any further support.
I am really glad that you manage to resolve this issue. In case you want to show the hierarchical data as well you could try our igGHierarchicalGrid:
http://help.infragistics.com/NetAdvantage/jQuery/2012.2/CLR4.0?page=igHierarchicalGrid_Initializing.html
http://ko.infragistics.com/products/jquery/sample/hierarchical-grid/bind-to-dataset
If you need more information about this grid please do not hesitate to ask.
Hi Elena,
Thank you for the advice. I did have some hierarchical data in the model (although I was not trying to display it) When I changed to a flat model the grid displayed.
So Thank you for that.
I do have a follow up though in that what if i wanted to display the hierarchical data, my two models are
public class Users { public virtual int UserId { get; set; } public virtual string Username { get; set; } public virtual string Password { get; set; } public virtual IList<Roles> Roles { get; set; } } public class Roles { public virtual int RoleId { get; set; } public virtual string RoleName { get; set; } public virtual IList<Users> UsersInRole { get; set; } }
How would I go about binding these to hierarchical grid or is it just not possible.
Thank you
Could you try to delete the following setting .ResponseDataKey("") since you won’t need this unless you provide wrapped json data source. Furthermore could you please provide me with more information if the data source that you provide to igGrid is hierarchical. Also I have created a small sample for you in order to show how you can use our igGird in MVC so you can try to compare the code from your application to the one in the sample in order to investigate the issue.
If this doesn’t resolve the issue would you please provide me with a small sample where it is reproducible so I can research it further.