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

Grid Detail

1 Answer 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 25 Feb 2015, 01:43 PM
I have created a grid which is bound to a list of workgroups. Each workgroup has a list of Agents which I want to show as detail.

The only way I got this working was by doing a  client detail template and creating a new grid. This means doing another read of data which i did not really want to do. 

Can someone advise a better way to do this. Also suggest a good way to style my details as I don't want them shown as a standard grid but actually a list. 
  
Current code:

   <div id="clientsDb">
    <%: Html.Kendo().Grid<ASML_Scheduler.ScheduleService.WorkgroupViewData>()
        .Name("grid")
         .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("Workgroups_Read", "Home", new { name = ViewData["LoggedInUser"] }))
            )
        .Columns(columns =>
        {
            columns.Bound(c => c.WorkgroupName).Width(140);
            columns.Bound(c => c.TotalAgents).Width(75);
            columns.Bound(c => c.AgentsLoggedOn).Width(75);

        })       
        .HtmlAttributes(new { style = "height: 380px;" })
        .Scrollable()
        .Groupable()
        .Sortable()        
        .ClientDetailTemplateId("client-template")
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5))     
     %>
 </div>

<script id=" Code:client-template" type="text/x-kendo-template">     
  <%: Html.Kendo().Grid<ASML_Scheduler.ScheduleService.AgentViewData>()
      .Name("grid_#=WorkgroupName#") 
        .DataSource(dataSource =>  
          dataSource.Ajax().Read(read => read.Action("Agents_Read", "Home", new {workgroupname= "#=WorkgroupName#", name = ViewData["LoggedInUser"] }))
      )      
      .Columns(columns =>
      {
          columns.Bound(product => product.AgentName);
          columns.Bound(product => product.IsLoggedOn);
      })       
      .ToClientTemplate()
    %>    
</script>

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 27 Feb 2015, 09:44 AM
Hi Robert,

You can achieve similar behavior by using controller that return the Agents as a collection contained in each Wokrgroup, then use Grid's the detailInit event to render the Agents in a list.
Another approach would be to use the TreeList widget instead of a Grid.

Regards,
Alexander Popov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or