Grid UI with List<T>

2 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    2 posts
    Member since:
    Jul 2016

    Posted 26 Jul Link to this post

    Here is the specific issue (for which hours of digging through forums and the like did no good):
    Data is populated into a List<T> of objects that will then be bound to the Grid object on the index page
    Inside the .chtml index file:

    @(Html.Kendo().Grid<HydraulicFracturing.Models.HydraulicFracturings>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(p => p.AdditiveName).Title("Additive Name");
            columns.Bound(p => p.Vendor).Title("Vendor");
            columns.Bound(p => p.Function).Title("Function");
            columns.Bound(p => p.HealthHazardScore).Title("Health Hazard Score");
            columns.Bound(p => p.EnvironmentalHazardScore).Title("Environmental Hazard Score");
            columns.Bound(p => p.TotalHazardScore).Title("Total Hazard Score");
        })
        .Groupable()
          .Scrollable()
            .Groupable()
            .Sortable()
            .Pageable(pageable => pageable
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
                .BindTo(enumerable)
            //.DataSource(datasource => datasource
            //   .Ajax()
            //.Read(read => read.Action("Query_Read", "Home"))
            //.PageSize(20)

    Note: that what is commented out does not work (more on that later…)
    Note: “enumerable” is an object of type IEnumerable<T> bound to this grid.  The above populates fine, but features such as Groupable are not working.
    Note: Little of this code is changed from examples provided on the website.
    Code from the referenced control (assuming that you wanted the .DataSource(… part to work – which is does not

    public ActionResult Query_Read([DataSourceRequest]DataSourceRequest request)
            {
                var x = Json(GetQueryData().ToDataSourceResult(request));
                return x;
            }

            private static IEnumerable<HydraulicFracturing.Models.HydraulicFracturings> GetQueryData()
            {
                var northwind = HydraulicFracturing.Models.QueryData.GetInstance();

                return northwind.fracturingList.Select(order => new HydraulicFracturing.Models.HydraulicFracturings
                {
                    AdditiveName = order.AdditiveName,
                    Vendor = order.Vendor,
                    Function = order.Function,
                    HealthHazardScore = order.HealthHazardScore,
                    PhysicalHazardScore = order.PhysicalHazardScore,
                    EnvironmentalHazardScore = order.EnvironmentalHazardScore,
                    TotalHazardScore = order.TotalHazardScore
                });
            }

    Changing over from using the “BindTo(…)” to the DataSource(…) does not work.
    Attempting to use “Groupable()” does not work.
    This code is taken primarily from examples on pages.

    Was hoping for some degree of insight into what could be going on here….

    Thanks in advance.
  2. Jeremy
    Jeremy avatar
    2 posts
    Member since:
    Jul 2016

    Posted 26 Jul Link to this post

    Move to closed....

    The problem can be corrected by starting a new Telerik MVC 5 project and rebuilding. Not sure what was missed on the initial creation, but this did the trick :P

  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top