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

[Solved] Ajax hierarchy expanding/getdata issue

4 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brian Solli
Top achievements
Rank 1
Brian Solli asked on 13 Jan 2011, 11:08 AM
We have a hierarchy of 2 levels (for now). First level gets listed fine, but expanding to second level works very strange regarding fetching of data.
1. If I expand the first row, that row will expand and fetch data, but no other rows will be able to fetch data.
2. If I expand row 8, I'm able to expand row 7, then row 6 etc (which fetch data and works ok). But not row 9! So the rule seems that you cannot retrieve data if you expand a row after the one you just expanded.

GRID LAYOUT
@(Html.Telerik().Grid<PlantDto>()
    .Name("Plants")
    .Columns(columns =>
    {
        columns.Bound(plant => plant.Title);
    })
            .DetailView(details => details.ClientTemplate(Html.Telerik().Grid<ProjectDto>().Name("Projects" + Guid.NewGuid())
            .Columns(columns =>
            {
                columns.Bound(p => p.Name).Width(101);
                columns.Bound(p => p.Description).Width(140);
            })
                  .DataBinding(dataBinding => dataBinding.Ajax()
                    .Select("_ProjectsForPlant", "User", new { plantId = "<#= Id #>" }))
                        .Pageable()
                        .Sortable()
                    .ToHtmlString()
            )
        )
            .Pageable(paging => paging.PageSize(10))
            .DataBinding(dataBinding => dataBinding.Ajax()
                                        .Select("_PlantList", "User", new { id = Model.UserId }))
    )

CONTROLLER

[GridAction]
     public ActionResult _PlantList(long id)
     {
         var viewModel = UserAccessEditViewModel.CreateViewModel(_personService, id);
         return View(new GridModel(viewModel.Plants.OrderBy(p => p.Title)));
     }
     [GridAction]
     public ActionResult _ProjectsForPlant(string plantId)
     {
         var projects = _projectService.FindProjectsBelongingToPlant(plantId);
         return View(new GridModel(projects));
     }

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 13 Jan 2011, 12:54 PM
Hi Brian Solli,

 The name of the child grid must contain "<#= #>" in order to be automatically generated when a new detail template is instantiated on the client-side. Now all grids have the same name (which results to same HTML id attribute). You can try this instead:

(Html.Telerik().Grid<PlantDto>()
    .Name("Plants")
    .Columns(columns =>
    {
        columns.Bound(plant => plant.Title);
    })
            .DetailView(details => details.ClientTemplate(Html.Telerik().Grid<ProjectDto>().Name("Projects_<#= Id #>")
            .Columns(columns =>
            {
                columns.Bound(p => p.Name).Width(101);
                columns.Bound(p => p.Description).Width(140);
            })
                  .DataBinding(dataBinding => dataBinding.Ajax()
                    .Select("_ProjectsForPlant", "User", new { plantId = "<#= Id #>" }))
                        .Pageable()
                        .Sortable()
                    .ToHtmlString()
            )
        )
            .Pageable(paging => paging.PageSize(10))
            .DataBinding(dataBinding => dataBinding.Ajax()
                                        .Select("_PlantList", "User", new { id = Model.UserId }))
    )

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Brian Solli
Top achievements
Rank 1
answered on 13 Jan 2011, 01:27 PM
Hi,

Thanks for the answer, but unfortunatly it doesn't work for us. When I expand now, no data is fetched for any row. if I remove the <#= id >, data is fetched but then we have the same issue as earlier.

Our grid is contained in a partial view within a tabcontrol. I think the problem might be with the Uri/routing to the controller for fetching the data? Do you idea?

Brian
0
Atanas Korchev
Telerik team
answered on 13 Jan 2011, 01:58 PM
Hello Brian Solli,

If the grid is contained inside a partial view rendered by a tabstrip (with ajax) make sure all required JavaScript files are registered by hand. I am sending a sample project showing how a sample implementation.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Brian Solli
Top achievements
Rank 1
answered on 13 Jan 2011, 02:23 PM
Hi,

I finally figured it out . The problem was that the id property used <#= id #> contained $ sign. Another issue is using a property with space in it.

My solution was to add another public string UniqueId property, which returns a Guid.NewGuid.ToString(); 
Maybe you should update the demo with rules about the it not containing space and invalid signs.

This thread can be closed.
Tags
Grid
Asked by
Brian Solli
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Brian Solli
Top achievements
Rank 1
Share this question
or