Chris
Chris

Reputation: 3129

KendoGrid not populating but it should be

I have a KendoGrid in my view and for some reason, its not populating and I have no idea why, all things show that it should, but it isn't wanting to, maybe I am missing something?

This is the order of events...

$(document).ready(function () {
    GetCatalogInfo();
})

function GetCatalogInfo() {
    $.ajax({
        type: "GET",
        url: URLParams.GetTheCatalog,
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (data, textStatus, jqXHR) {
            TheCatalogGrid(data);
        }
    })
}

here is my grid

function TheCatalogGrid(catalogData) {
    $("#CatalogGrid").kendoGrid({
        dataSource: {
            catalogData
        },
        columns: [{
            field: "GlobalGroupID",
            title: "GlobalGroupID",
            hidden: true
        },
        {
            field: "GlobalGroupName",
            title: "GroupName"
        }],
        scrollable: true,
        sortable: true,
        pageable: false,
        selectable: "row",
        height: 275
    })
}

My Controller looks like this

public JsonResult GetCatalog()
{
    List<GridCatalog> lst = new List<GridCatalog>();
        _Catalog = CatalogObjectFactory.GetCatalog("C:\\ProgramData\\AdvanceWare\\CatalogDLLs", "CabParts", "2015.09.28-22.14.15");
        //  comment out for debugging catalog with reference to the CatalogsProject
        if (_Catalog != null)
        {
            _GlobalGroupOptions = new GlobalGroupOptions(_Catalog);
            var query = from ggo in _GlobalGroupOptions
                        select new
                        {
                            GlobalGroupID = ggo.GlobalGroup.GlobalGroupID,
                            GlobalGroupLevel = ggo.GlobalGroup.Level,
                            GlobalGroupName = ggo.GlobalGroup.GlobalGroupName,
                            IsRequired = (ggo.GlobalGroup.Required == 0) ? "" : "!",
                            OptionName = ggo.CurrentGlobalOption == null ? "" : (ggo.IsValid ? ggo.CurrentGlobalOption.OptionName : ""),
                            CurrentOptionID = ggo.CurrentGlobalOption == null ? 0 : ggo.CurrentGlobalOption.OptionID,
                            InvalidOption = ggo.CurrentGlobalOption == null ? "" : (ggo.IsValid ? "" : ggo.CurrentGlobalOption.OptionName)
                        };
        foreach(var item in query)
        {
            lst.Add(new GridCatalog
            {
                GlobalGroupID = item.GlobalGroupID,
                GlobalGroupName = item.GlobalGroupName
            });
        }
    }
    return Json(lst, JsonRequestBehavior.AllowGet);
}

Here is the Data Class

public class GridCatalog
{
    public int GlobalGroupID { get; set; }
    public string GlobalGroupName { get; set; }
    public int GlobalGroupLevel { get; set; }
    public string IsRequired { get; set; }
    public string OptionName { get; set; }
    public int CurrentOptionID { get; set; }
    public string InvalidOption { get; set; }
}

The data is present in my lst variable, I have double checked this while stepping through the controller and when I use the developer tools in Google Chrome, and here is a pic of the data that is from my watch in Chrome

Captured Data

Here is the code in my view

<div id="CatalogGrid">

</div>

The Data is there but for some reason my grid doesn't want to populate

Upvotes: 0

Views: 35

Answers (1)

Omar Martinez
Omar Martinez

Reputation: 439

I think that your problem is in the DataSource, try this:

dataSource: {
    type: "json",
    data: catalogData,
}

Upvotes: 1

Related Questions