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

Expand First Group, Collapse Second

4 Answers 527 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peggy
Top achievements
Rank 1
Peggy asked on 19 Mar 2015, 05:01 PM
I have a (razor) Grid with two groups added:
   .Group(groups => groups.Add(dd => dd.grp1))
   .Group(groups => groups.Add(dd => dd.grp2)

I have been able to find examples to collapse ALL groups, but am wondering how to get a handle to just grp2 so that is the only one collapsed?
The data in grp2 can be a variety of random numbers , so something like below will not work for me:
    grid.collapseGroup(".k-grouping-row:contains(Beverage)");

Thanks in advance for your response.

4 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 20 Mar 2015, 08:38 AM

Hello Peggy,

The group field (or it's title if set) is also part of the grouping row text, so you could use it in the :contains() selector instead of the field value.
E.g.

grid.collapseGroup(".k-grouping-row:contains(grp2)");

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Peggy
Top achievements
Rank 1
answered on 20 Mar 2015, 04:06 PM
Thanks for the quick reply, unfortunately, I still haven't gotten this to work. I've attached my example. Can you take a look and let me know what I am doing wrong?
Thanks so much!
0
Dimiter Madjarov
Telerik team
answered on 23 Mar 2015, 08:32 AM

Hello Peggy,

Please excuse me for the inconvenience. You could use the following approach a pass the group rows one by one to the collapseGroup method.
E.g.

function dataBound(e) {
    var grid = $("#grid").data("kendoGrid");
    $(".k-grouping-row:contains(Discontinued)").each(function () {
        grid.collapseGroup(this);
    });
}

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Peggy
Top achievements
Rank 1
answered on 23 Mar 2015, 12:16 PM
Thanks Dimiter, this works perfect for me!
Tags
Grid
Asked by
Peggy
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Peggy
Top achievements
Rank 1
Share this question
or