This is a migrated thread and some comments may be shown as answers.

Grid UI with List<T>

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 26 Jul 2016, 05:18 PM
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.

1 Answer, 1 is accepted

Sort by
0
Jeremy
Top achievements
Rank 1
answered on 26 Jul 2016, 06:26 PM

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

Tags
Grid
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Jeremy
Top achievements
Rank 1
Share this question
or