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

Server Heirarchy examples

4 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 13 Nov 2017, 04:21 AM

Is there a server binding hierarchy web forms example floating around out there?

I see example projects: server-hierarchy and server-binding but am having trouble understanding how to use it in a web forms based MVC project.

 

In the view for server-binding example:

@model IEnumerable<KendoGridServerBinding.Models.Product>
 
@(Html.Kendo().Grid(Model) // Bind the grid to the Model property of the view

 

and in the view for server-hierarchy example project:

@(Html.Kendo().Grid((IEnumerable<KendoGridServerHierarchy.Models.Category>)ViewBag.Categories)

 

Can someone explain the difference for referencing the controller server data in the two example projects?

4 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 15 Nov 2017, 08:34 AM
Hello Erik,

In both examples the data is passed directly to the Grid component. The difference is where the items are contained. In the first case they are available in the model and in the second case the items are in the ViewBag.

With that said, the  Kendo MVC wrappers are not intended to work with WebForms. If you have a WebForms application I would recommend using our UI for ASP.NET AJAX controls. They are built specifically for working in WebForms applications. 


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Erik
Top achievements
Rank 1
answered on 15 Nov 2017, 01:25 PM
Maybe I mispoke, I am using System.Web.Mvc.WebFormViewEngine instead of Razor.  I believe I should still be using 'UI for ASP.NET MVC' controls.  I have been thus far in my project.
0
Erik
Top achievements
Rank 1
answered on 15 Nov 2017, 04:07 PM

And a follow-up question on the server-hierarchy example project:

What is the "item" referencing?  Is it related to entity framework? Or something else?

.DetailTemplate(@<text>
        @(Html.Kendo().Grid(item.Products)
              .Name(string.Format("product_grid_{0}", item.CategoryID)) // the Name() should be unique
              .Columns(columns =>
              {
                  columns.Bound(product => product.ProductID);
                  columns.Bound(product => product.ProductName);
              })
              .Pageable()
        )
      </text>)

 

How does it "know" a property of Products and CategoryID?

0
Viktor Tachev
Telerik team
answered on 17 Nov 2017, 01:05 PM
Hi Erik,

The item in the code snippet is referring to the dataItem of the parent row. Thus, all fields that are present in the parent row Model can be accessed.

The parent row contains a field Products that is a collection. That is passed as the main data to the detail Grid. Since the name of each component should be unique the CategoryID is included in the name. This field is also available in the Category Model.


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Erik
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Erik
Top achievements
Rank 1
Share this question
or