Hi,
I have implemented remote paging as shown in documentation.
Below is the complete markup for grid:
<style type="text/css"> #testGrid { table-layout: auto!important; }
#testGrid_scroll { overflow-x: auto!important; }
#testGrid>tbody>tr>td { white-space: nowrap; } </style>
@(Html.Infragistics().Grid<testData>(Model).ID("testGrid")
.AutoGenerateColumns(true) .FixedHeaders(false)
.Features(features => { features.Paging().PageSize(50).Type(OpType.Remote); features.Selection().Mode(SelectionMode.Row).MultipleSelection(false).Activation(true); features.Filtering().Mode(FilterMode.Advanced).CaseSensitive(false); features.Sorting(); features.Resizing(); })
.DataSourceUrl(Url.Action("GetTestGridData"))
.Height("655px") .DataBind() .Render() )
But I am getting javascript error:
Unhandled exception at line 25, column 75466 in http://localhost:23387/Scripts/Ig/modules/infragistics.ui.grid.framework.js
0x800a139e - Microsoft JScript runtime error: You have autoGenerateColumns set to false, but there are no columns defined in the grid. Please set autoGenerateColumns to true, or specify columns manually
Any help would be appreciated.
Hi Sanjay,
Auto generation of columns depends on the initially supplied data. Internally Infragistics.Web.Mvc.dll inspects the data and generates column definitions. If you didn't pass any data to the view model then the grid outputs the message you're observing.
I guess that your controller doesn't return any data to the view, so you should change it to look like this:
Hope this helps,
Martin Pavlov
Infragistics, Inc.
Hi Martin,
The problem is something else, since I am getting data and grid is also working for LOCAL PAGING.
Its throwing that error only when I change it to REMOTE Paging.
Below is the code controller code:
[GridDataSourceAction]public ActionResult GetMeasurementGridData(){ Measure measureData = AppCacheManager.GetCacheData<Measure>("Measurements"); return View(measureData.AsQueryable()); }
The only change is this method for remote paging and I have declared it in markup as well
.DataSourceUrl(Url.Action("GetMeasurementGridData"))
Still I am getting error.
Can you please post the action method which is initializing the view. The problem is in it. As I already said you need to pass data to the view initially.
If your view is named "Index" then your "Index" action method should look like this:
Best regards,Martin PavlovInfragistics, Inc.
Looks like I got the ROOT cause of the problem.
The problem is in declaration of Model.
@model IQueryable<GridDataBinding.Models.Product> -----------> THIS LINE MAKES THE GRID WORK
@model MyDomainModel.ModelData ------------> THIS LINE THROWS ERROR
Could not understand the problem here ??
Thanks Martin. I would check on that.
I also found that same error is thrown when I tried to bind grid to Datatable
@(Html.Infragistics().Grid<System.Data.DataTable>(Model.SpectData) .ID("mGrid") .AutoGenerateColumns(true) .FixedHeaders(false) .Features(features => { features.Paging().PageSize(50).Type(OpType.Local); features.Selection().Mode(SelectionMode.Row).MultipleSelection(false).Activation(true); features.Filtering().Mode(FilterMode.Advanced).CaseSensitive(false); features.Sorting(); features.Resizing(); }) .Height("655px") .DataBind() .Render() )
In addition to this, it also look like this error is thrown when I have data with more that 80-90 columns. In my project I have numerous grids where I have implemented REMOTE paging.
BUT I am getting error only for 2 grids and for both grids the column is more than 120.
Not sure what's wrong with these 2 grids.
Your action method looks good. I'm not sure what is wrong here. The next step is to look at the generated page source code(in the browser). In the source search for "#testGrid" and you'll find the JavaScript code of the igGrid. You can look at the dataSource option which should have inline JSON data.
I'm also attaching my test sample for you to investigate. You need to put your copy of Infragistics.Web.Mvc.dll into the project bin folder in order to make it work.
Below is the code:
public ActionResult Measurements(){ Measurements measurements =AppCacheManager.GetCacheData<Measurements>("Measurements");
return PartialView(measurements);
}
Like I said earlier, the above code works for LOCAL paging the only issue is in remote paging.