Hierarchy Grid doesn't work properly

3 posts, 1 answers
  1. Oliver
    Oliver avatar
    6 posts
    Member since:
    Jun 2015

    Posted 05 Jan Link to this post

    Hello,

    it seems the hierarchy-function only works the first time. If i click on the symbol for another node the controller action fires, data comes back, but for whatever reason the grid doesn't show the data in the grid.

     I'm not quite sure why this doesn't work, but to me it seems like tha grid doesn't refresh itself.

     

    View:

    @using DAKCrmImport.Web.Models;
    @{
    ViewBag.Title = "Index";
    }
    <h2>Profilübersicht</h2>
    @(Html.Kendo().Grid<CrmProfileGridVM>().Name("grid-crmprofiles").BindTo(Model).Columns(c =>
    {
    //<a class='button-action grid-details' onclick='showProfile(this)' title='Details'>button details</a>
    c.Template(t => { }).HeaderTemplate("")
    .ClientTemplate(@"
    <a class='button grid-button button-details' title='Details' id='bt-profile-details'>button details</a>
    <a class='button grid-button button-delete' onclick='' title='Löschen' id='bt-profile-delete'>button delete</a>
    <a class='button grid-button button-edit' onclick='' title='Bearbeiten' id='bt-profile-edit'>button edit</a>
    <a class='button grid-button button-create' onclick='' title='Job erstellen' id='bt-profile-createjob'>button create</a>").Width(250);
    c.Bound(i => i.Name);
    c.Bound(i => i.JobCount);
    c.Bound(i => i.UserGroup);
    c.Bound(i => i.CreatedBy);
    c.Bound(i => i.CreatedAt);
    c.Bound(i => i.LastUpdatedBy);
    c.Bound(i => i.LastUpdatedAt);
    })
    .ToolBar(toolBar => toolBar.Template("<a href='javascript: void(0)' class='button button-create2' title='Neues Profil anlegen' id='bt-profile-create'>button create</a>"))
    .HtmlAttributes(new { style = "height: 680px;" })
    .Editable(editable => editable.Mode(GridEditMode.PopUp))
    .Scrollable()
    .ClientDetailTemplateId("template-grid-crmprofile")
    .Groupable()
    .Sortable()
    .Pageable(pageable => pageable
    .Refresh(true)
    .PageSizes(true)
    .ButtonCount(5))
    .Filterable()
    .DataSource(dataSource => dataSource
    .Ajax()
    .ServerOperation(false)
    .Model(model => model.Id(p => p.Id))
    .Read(r => r.Action("Read", "CrmProfile"))
    ))
    <script id="template-grid-crmprofile" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<CrmJobGridVM>()
    .Name("grid-crmjobs")
    .Columns(c =>
    {
    c.Bound(j => j.CreatedBy);
    c.Bound(j => j.JobStatus);
    c.Bound(j => j.CreatedAt);
    c.Bound(j => j.EndedAt);
    c.Bound(j => j.CrmObjectCount);
    })
    .DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(10)
    .Read(r => r.Action("GetJobsByProfileId", "CrmJob", new { profileId = "#=Id#" }))
    )
    .ClientDetailTemplateId("template-grid-crmjob")
    .Pageable()
    .Sortable()
    .ToClientTemplate()
    )
    </script>
    <script id="template-grid-crmjob" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<CrmObjectGridVM>()
    .Name("grid-crmobjects")
    .Columns(c =>
    {
    c.Template(t => { }).HeaderTemplate("").ClientTemplate("<a class='button grid-button button-details bt-object-details' title='Details'>button details</a>")
    .Width(50);
    c.Bound(o => o.OrdnungsbegriffTypString);
    c.Bound(o => o.OrdnungsbegriffWert);
    c.Bound(o => o.IsProcessedString);
    c.Bound(o => o.Error);
    })
    .DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(10)
    .Read(r => r.Action("GetObjectsByJobId", "CrmObject", new { jobId = "#=Id#" }))
    )
    .Pageable()
    .Sortable()
    .HtmlAttributes(new { @class = "gr-crmobjects" })
    .ToClientTemplate()
    )
    </script>

     

    Controller-Action:

    public virtual ActionResult GetJobsByProfileId(int profileId, [DataSourceRequest] DataSourceRequest request)
    {
                return Json(Mapper.Map<CrmJobGridVM[]>(db.GetJobsByProfileId(profileId)).ToDataSourceResult(request));
    }

     

    I'd really appreciate some help.

  2. Oliver
    Oliver avatar
    6 posts
    Member since:
    Jun 2015

    Posted 05 Jan Link to this post

    I got it myself .. apparently I need to use .Name("grid_#=Id#").
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 07 Jan Link to this post

    Hello Oliver,

     

    Indeed detail Grid must have unique name and using templates is a way to guarantee this.

     

    Regards,
    Nikolay Rusev
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top