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

Adding a Column to a Grid doesn't work when binding data to property in ViewBag

0 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michel
Top achievements
Rank 1
Michel asked on 12 Jul 2012, 12:20 AM
Hi,

I'm trying to add to a Grid a column that doesn't exist in the model. That column only have an icon with some functionality. The problem is the icons doesn't appear when binding data from a property in the ViewBag:

@(Html.Kendo().Grid<Models.Location>()
    .Name("availableStops")
    .BindTo((IEnumerable<Models.Location>)ViewBag.AvailableLocations)
    .Columns(columns =>
    {
         columns.Bound(p => p.Id).Title("ID");
         columns.Bound(p => p.StopLocation).Title("Description");
         columns.Template(@<text></text>).ClientTemplate("<span class='k-icon k-add' title='Add' style='cursor:pointer;' onclick='addStop(this)'></span>").Title("Add");
      })
     .DataSource(dataSource => dataSource.Server().Model(model => model.Id(p => p.IRN)))
     )

and appear when I'm populating the grid using an ajax call:

@(Html.Kendo().Grid<SpyMobileLibraryRoute.Models.UISpyFmtLOC>()
     .Name("availableStops")
     .Columns(columns =>
      {
          columns.Bound(p => p.Id).Title("ID");
          columns.Bound(p => p.StopLocation).Title("Description");
          columns.Template(@<text></text>).ClientTemplate("<span class='k-icon k-add' title='Add' style='cursor:pointer;' onclick='addStop(this)'></span>").Title("Add");
       })
        .DataSource(dataSource => dataSource.Ajax().Read(read => read.Action("GetLocations", "Location")))
)

Thanks in advance.

No answers yet. Maybe you can help?

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