Grid Detail

2 posts, 0 answers
  1. Robert
    Robert avatar
    5 posts
    Member since:
    Dec 2014

    Posted 25 Feb 2015 Link to this post

    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>
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 27 Feb 2015 Link to this post

    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.

     
Back to Top