Hi,
when call page I see only busy indicator, but no data is displayed.
This is the code I use:
.cshtml
@(Html.Infragistics().Grid<TargheAutorizzate>() .ID("GridTarghe") .AutoGenerateColumns(true) .DataSourceUrl(Url.Action("TargheAutorizzateList")).DataBind().Render() )
TargheAutorizzate is my model and TargheAutorizzateList is my Action.
.cs
[Infragistics.Web.Mvc.GridDataSourceAction] [ActionName("TargheAutorizzateList")] public ActionResult TargheAutorizzateList() { var targheautorizzate = db.TargheAutorizzate.Include(t => t.Enumerativi) .Where(t => t.DataEliminazione == null).OrderBy(t => t.Targa); return View(targheautorizzate.ToList()); } This is the method I use in the code. The method is executed but no data is displayed. _layout.cshtml <link href="@Url.Content("~/Content/IGStyles/base/ig.ui.min.css")" rel="stylesheet" type="text/css" /> <link href="@Url.Content("~/Content/IGStyles/ig/jquery.ui.custom.css")" rel="stylesheet" type="text/css" /> <script src="@Url.Content("~/Scripts/IG/jquery-ui.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/IG/jquery.tmpl.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/IG/ig.ui.min.js")" type="text/javascript"></script> This are style sheets and scripts that I have included in _layout page.
[Infragistics.Web.Mvc.GridDataSourceAction] [ActionName("TargheAutorizzateList")] public ActionResult TargheAutorizzateList() { var targheautorizzate = db.TargheAutorizzate.Include(t => t.Enumerativi) .Where(t => t.DataEliminazione == null).OrderBy(t => t.Targa); return View(targheautorizzate.ToList()); }
This is the method I use in the code.
The method is executed but no data is displayed.
_layout.cshtml
<link href="@Url.Content("~/Content/IGStyles/base/ig.ui.min.css")" rel="stylesheet" type="text/css" /> <link href="@Url.Content("~/Content/IGStyles/ig/jquery.ui.custom.css")" rel="stylesheet" type="text/css" /> <script src="@Url.Content("~/Scripts/IG/jquery-ui.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/IG/jquery.tmpl.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/IG/ig.ui.min.js")" type="text/javascript"></script>
Anyone can help me?
Thanks you in advance.
Mirko
hi Mirko,
i think what happens is that you have AutoGenerateColumns = true, but at the same time the grid is not initially supplied with a DataSource. So it sends just the initialization scritpts to the client (browser), but it cannot generate columns because there is no data from which to retrieve the columns info, it needs to do a request first, specified by DataSourceUrl.
There are to solutions to the issue you're experiencing:
1) Supply a data source in the View: so instead of
Grid<TargheAutorizzate>() you can just put Grid(Model)
The additional advantage of doing it, is that there will be only a single request to your view, because the data will be sent automatically by the MVC Grid inline in the response, so there won't be any need for a second request just to fetch and bind the data.
2) Keep the above as is, but instead of AutoGenerateColumns=true, define your columns manually
Let me know if this solves your case. Thank you!
Angel
Hello Mirko,
I am following up to see, were you able to show data in grid based on the information Angel provided above?
Update me if you have any further questions with this matter.
Thanks,
Bhadresh
Hi Bhadresh,
I haven't had time to try what Angel suggests until today.
I binded Model data to grid like Angel suggests. This is the code in cshtml
@(Html.Infragistics().Grid(Model).ID("GridTarghe").AutoGenerateColumns(true).DataSourceUrl(Url.Action("TargheAutorizzateList")).DataBind().Render())
and this is another try
@(Html.Infragistics().Grid(Model).ID("GridTarghe").AutoGenerateColumns(true).DataBind().Render()
)
When the request is executed the runtime throw this exception:
{"There is already an open DataReader associated with this Command which must be closed first."}
In the controller I have an index method that runs when the page is requested.
If I comment this, a new System.NullReference exception is thrown because Model is null.
I can't figure it out!
Thank you in advance.
Have you set columns in markup based on the suggestion Angel provided? Provide me with markup of the grid with relevant dependencies, if any further assistance needed.
Please let me know if I may be of further assistance.