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

Hierarchy Grid doesn't work properly

2 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 05 Jan 2016, 06:02 AM

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 Answers, 1 is accepted

Sort by
0
Oliver
Top achievements
Rank 1
answered on 05 Jan 2016, 06:09 AM
I got it myself .. apparently I need to use .Name("grid_#=Id#").
0
Accepted
Nikolay Rusev
Telerik team
answered on 07 Jan 2016, 09:22 AM

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
Tags
Grid
Asked by
Oliver
Top achievements
Rank 1
Answers by
Oliver
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or