开发者

Telerik MVC Grid won't load data into details table (subtable)

开发者 https://www.devze.com 2023-02-03 16:29 出处:网络
I have a list of Plants and assosiated Projects. I want to output this in a table with all the Plants and use Telerik.Grid to expand a Plant, show a Telerik.Grid with associated Projects. I want the P

I have a list of Plants and assosiated Projects. I want to output this in a table with all the Plants and use Telerik.Grid to expand a Plant, show a Telerik.Grid with associated Projects. I want the Projects to be dynamically loaded with Ajax.

The code for the grid:

@(Html.Telerik().Grid<PlantDto>()
  .Name("Plants")
  .Columns(columns =>
    {
        columns.Bound(plant => plant.Title);
    })
  .DetailView(details => details.ClientTemplate(
    Html.Telerik().Grid<ProjectDto>()
    .Name("Plant_<#= Id #>")
    .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("ProjectsForPlant", "User", new { plantId = "<#= Id #>" }))
        .ToHtmlString()
  ))
  .DataBinding(dataBinding => dataBinding.Ajax().Select("PlantsForUser", "User"))
)

The initial data is loaded into the grid just fine (the list of Plants) but when I expand a plant I just get an empty sub-table.

Looking in FireBug there are no calls to the server. The controller that should serve the list of projects is never called.

Anyone have an idea on what 开发者_如何学Pythonit could be?

Update: Looks like what was causing trouble was that the plant.id had an "$" in it. Like "PCD$ODIN". Looks like that made life difficult for the JavaScript.


I compared your configuration to the one here and it looks identical. Test whether this Select method:

.Select("ProjectsForPlant", "User", new { plantId = "<#= Id #>" }))

set the plant id properly and if you need to name it exactly the same as the Id field instead of plantId, i.e.:

.Select("ProjectsForPlant", "User", new { Id = "<#= Id #>" }))
0

精彩评论

暂无评论...
验证码 换一张
取 消