Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
190
igGrid don't display data
posted

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.
Anyone can help me?
Thanks you in advance.
Mirko

 

Parents
  • 24671
    posted

    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

     

Reply Children