Default Grouping on Grid

6 posts, 0 answers
  1. Ashwin
    Ashwin avatar
    3 posts
    Member since:
    Jun 2012

    Posted 11 Jul 2012 Link to this post

    Is there anyway to provide default grouping when the grid is rendered on the view? For example, in the grid below, I want to group by Type, by default. Thanks.

    @(Html.Kendo().Grid<SomeModel>()
            .Name("Grid")
            .Columns(columns =>
            {  
                columns.Bound(p => p.TYPE).Title("Type");          
                columns.Bound(p => p.NAME).Title("Name");
                columns.Bound(p => p.CITY).Title("City");
            })        
            .Sortable()
            .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(100)
                    .Read(read => read.Action("GetInfo", "Summary"))
            )
    .Groupable (// group by first column)
  2. Victor
    Victor avatar
    167 posts
    Member since:
    Nov 2010

    Posted 11 Jul 2012 Link to this post

    Nowadays you configure it using the datasource, for example

    .DataSource(ds => ds.Ajax().Group(g => g.Add(c => c.Name)))

    /Victor
  3. Ashwin
    Ashwin avatar
    3 posts
    Member since:
    Jun 2012

    Posted 11 Jul 2012 Link to this post

    That worked. Thanks!
  4. Raj
    Raj avatar
    34 posts
    Member since:
    Nov 2016

    Posted 28 Feb 2017 in reply to Victor Link to this post

    Hello Victor 

    I would like to display only the value when default grouping is enabled. Instead of displaying the column name and its corresponding value i would like to have only value to be display. In the attached file you can see Description and Facility Name are displayed on all groups, i would like to have only value without Description and Facility Name.

    Thanks

    Raj

  5. Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    1285 posts

    Posted 03 Mar 2017 Link to this post

    Hello Raj,

    You can use the ClientGroupHeaderTemplate("#: value #") in the respective columns configurations, e.g.:


    ClientGroupHeaderTemplate(System.String)
     
    Sets the client group template for the column.
     
    Parameters
     
    value System.String
     
    The template

    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.CustomerViewModel>()
            .Name("grid")
            .Columns(columns =>
            {
                columns.Bound(c => c.ContactName)
                    .ClientGroupHeaderTemplate("#: value #")
                  .Width(240);
                columns.Bound(c => c.ContactTitle).ClientGroupHeaderTemplate("#: value #");
                ...        })
            ...
            .DataSource(dataSource => dataSource
                .Ajax()
                .Group(g => g.Add(c => c.ContactName))
                .Read(read => read.Action("Customers_Read", "Grid"))
                .PageSize(20)
            )
        )

    You can find more information about the Grid columns.groupHeaderTemplate and the available field references inside the template in the following API reference:

    http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.groupHeaderTemplate

    I hope this helps.

    On a side note, this thread is rather outdated, and in general I can suggest starting a new one in such cases, so that all information in the subsequent discussion will be up-to-date, and will be relevant to the current Kendo UI version. Thank you in advance.

    Regards,
    Dimiter Topalov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Raj
    Raj avatar
    34 posts
    Member since:
    Nov 2016

    Posted 03 Mar 2017 in reply to Dimiter Topalov Link to this post

    Thanks Dimiter.

    It Worked and yes i will open new threads if there are any outdated posts.

     

    Thanks

    Raj

Back to Top