Dynamic Multipl Column Group Titles

6 posts, 0 answers
  1. Jako
    Jako avatar
    107 posts
    Member since:
    Apr 2012

    Posted 15 Dec 2014 Link to this post

    Hello

    I was wondering how I can achieve dynamic multiple column headers. Currently I have a product followed by six columns , each a pair of Quantity and Price for past three years from selected year. I wish to group each Quantity & Price of each year under a title of the year . See example.

    Before the update with multiple headers I as injecting a <tr> rows with javascript after the first table element, but this doesnt export with grid.

    Help much appreciated

    columns.Group(group => group
    .Title("Contact Info") ****** DYNAMIC HOW **** ????
    .Columns(info => {
    info.Bound(x => x.ContactTitle).Width(200);
    info.Bound(x => x.ContactName).Width(200);
    info.Group(g => g.Title("Location")
    .Columns(location =>
    {
    location.Bound(c => c.Country).Width(200);
    location.Bound(c => c.City).Width(200);
    })
    );
    info.Bound(x => x.Phone);
    })
    );
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 17 Dec 2014 Link to this post

    Hi Jako,

    You can use a loop to create the appropriate column groups similar to the following:

    for (var idx = 0; idx < 3; idx++)
    {
        columns.Group(group => group
            .Title(DateTime.Now.AddYears(idx).ToString("yyyy"))
            .Columns(info =>
            {
                info.Bound(x => x.ContactTitle).Width(200);
                info.Bound(x => x.ContactName).Width(200);
                info.Group(g => g.Title("Location")
                    .Columns(location =>
                    {
                        location.Bound(c => c.Country).Width(200);
                        location.Bound(c => c.City).Width(200);
                    })
                );
                info.Bound(x => x.Phone);
            })
        );
    }



    Regards,
    Rosen
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Roohul
    Roohul avatar
    6 posts
    Member since:
    Apr 2009

    Posted 28 Apr 2015 in reply to Rosen Link to this post

    Can we get a complete working sample project for this?? Or more details? We have similar requirement, but year has to be picked from database..
  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 29 Apr 2015 Link to this post

    Hi Roohul,

    I'm afraid that we do not have such example available. 
    The snippet in question creates 3 column groups, one for each sequential year, where the each group title is the year.

    If you want to create multiple column groups base on the array of years loaded from the database. You will need to store them in a separate array, for example attached to the ViewModel, iterate the array and construct the column definition. For example:

    foreach (var year in (string[])ViewBag.Years)
    {
        columns.Group(group => group
            .Title(year)
            .Columns(info =>
            {
               //.... bound column declaration
            })
        );
    }


    Regards,
    Rosen
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. harmit
    harmit avatar
    1 posts
    Member since:
    Apr 2016

    Posted 02 May in reply to Rosen Link to this post

    how to bind column data dynamically with respect to title?
  7. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 03 May Link to this post

    Hello harmit,

    I'm afraid I could not understand your question. Could you please clarify? How it differs from the scenario discussed in this thread so far?

     

    Regards,
    Rosen
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready