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
105
Can't Get MVC grid to appear
posted

I've tried working from the chaining sample, and the page executes but no grid shows up. I only have 2 files, the controller and the view, though I am using model code for a simplistic data scenario.  I just want to see a grid configured on the server work and implement paging. I think I'll be a happy man if I can just look at Firebug and see my data coming back in chunks.  If someone could guide me to the missing magical statements, I would be eternally grateful. I love Infragistics, but the learning curve even after using them since 2006 is absurd.  Thanks in advance.  So here's the code:

Controller:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;

using Infragistics.Web.Mvc;

 

namespace ADT.website.Controllers

{

    public class GridChainingController : Controller

    {

        [ActionName("chaining")]

        public ActionResult Chaining()

        {

            var ds = buildClients().AsQueryable<Models.Client>();

            return View("Chaining", ds);

        }

 

        [GridDataSourceAction]

        [ActionName("ChainingGetData")]

        public ActionResult GetChainingData()

        {

            var ds = buildClients().AsQueryable<Models.Client>();

            return View("Chaining", ds);

        }

 

 

        private List<Models.Client> buildClients()

        {

            Models.Client item; List<Models.Client> items = new List<Models.Client>();

 

            for (int i = 0; i < 100; i++)

            {

                item = new Models.Client()

                {

                    Name = "Company " + i.ToString(),

                    ID = i,

                    City = "City " + i.ToString(),

                    State = "ST" + i.ToString(),

                    Entities = null

                };

                items.Add(item);

            }

 

            return items;

        }

    }

}

 

 


View:

@model IQueryable<ADT.website.Models.Client>

 

@using Infragistics.Web.Mvc;

 

@section HeadContent {

 

 

@(Html.Infragistics().Loader().ScriptPath("~/Infragistics/js").CssPath("~/Infragistics/css").Render())

}

 

@{

    ViewBag.Title = "Chaining";

 

 }   

 

    @(Html.Infragistics().Grid(Model).ID("grid2").Columns(column =>

{

    column.For(x => x.ID).HeaderText("Client ID").Width("100");

    column.For(x => x.Name).HeaderText("Name").Width("250px");

    column.For(x => x.City).HeaderText("City").Width("150px");

    column.For(x => x.State).HeaderText("State").Width("200px");

 

}).Features(features =>

{

    features.Paging().PageSize(12).PrevPageLabelText("Prev").NextPageLabelText("Next");

    features.Sorting().Mode(SortingMode.Single).ColumnSettings(settings =>

    {

        settings.ColumnSetting().ColumnKey("ProductID").AllowSorting(true);

    });

    // this sample also shows custom RowTemplate functionality

}).RowTemplate(

        "<tr><td> ${ID}  </td><td> ${Name} </td> <td> <span style=\"color:green;\"> Serial</span> : ${City} </td> <td> ${State} </td> </tr>"

        ).DataSourceUrl(Url.Action("ChainingGetData")).DataBind().Render()

    )

 

Controller:

    public class Client
    {
        public string Name { get; set; }
        public string City { get; set; }
        public string State { get; set; }
        public int ID { get; set; }
        public List<Entity> Entities { get; set; }
    }

 

  • 105
    Verified Answer
    posted

    Okay, you can disregard the above. It turned out that multiple copies (one minified, one not) of the jQuery library were getting pulled in and this caused the error out. So if your grid just won't appear, check _Layout, your view, and any calls to the loader to make sure you're not getting conflicting multiple loads of the same JS.