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

Changing from standard view to grid

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 22 Oct 2014, 03:11 AM
I have put together a simple app which include a few or the "out-of-the-box" index views. I would like to swap the table in these views for the Telerik grid.

I have the following action in the controller:

// GET: Assets
public ActionResult Index()
{
     
    var assets = db.Assets.Include(a => a.Equipment).Include(a => a.Owner).Include(a => a.ServiceCompany).Include(a => a.Site);
     
    return View(assets.ToList());
}

I have swapped out the table code and copied the following from the demo

@(Html.Kendo().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.Site).Title("Site").Width(130);
        columns.Bound(p => p.Location).Title("Location").Width(130);
        columns.Bound(p => p.Description).Title("Decriptopn").Width(130);
        columns.Bound(p => p.InstallDate).Title("Install Date").Width(130);
        columns.Bound(p => p.SerialNo).Title("Serial Number").Width(130);
    })
    .Pageable()
    .Sortable()
    .Scrollable(scr => scr.Height(430))
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .ServerOperation(false)
     )
)


When I try to view the 

System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=A circular reference was detected while serializing an object of type 'System.Data.Entity.DynamicProxies.Asset_ED2530D1AC046011EB9F014D634FE570012E36DD19818476965A4BF61659B91A'.
  Source=System.Web.Extensions
 
I changed the HTML helper line to

@(Html.Kendo().Grid<AMScan.Models.Asset>()

which then rendered the grid on the page without the exception however there was no data.

Can you please tell me what I am doing wrong.

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 23 Oct 2014, 04:07 PM
Hi Kevin,


Regarding the exception, you could take a look at the following documentation page, which describes the reason for it and the common ways to solve it.

The difference between the two type of helpers is that the one passes the Model as data and then uses it locally on the client side, as the other one requires you to configure a read action, which will return the Grid data.

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or