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

Issue with grid group headers- doesn't Collapse after grouping

1 Answer 456 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 04 May 2012, 08:42 AM
Hi,

I am using below code for the grid. I am getting below two issue

1) When grouping the columns, the group headers are expanded by default. I want to make them collapsed as soon as I do grouping on any column. Could someone help on this.
2) Also how can I find out the groupable column name, as I need to pass that column name to a different function for chart population.

Please help.

Here is code
---------------

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script src="Scripts/jquery.min.js" type="text/javascript"></script>
              <script src="Scripts/kendo.web.min.js" type="text/javascript"></script>
                <link href="styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
      <link href="styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
   
        <div id="example" class="k-content">
            <div id="grid"> </div>
            <script>
                $(document).ready(function () {
                    $("#grid").kendoGrid({
                        dataSource: {
                            type: "odata",
                            serverPaging: false,
                            serverSorting: false,
                            pageSize: 1000,
                            transport: {
                                read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
                            },
                            group: {
                                field: "ShipCity", aggregates: [
                                        { field: "OrderID", aggregate: "count" },
                                        { field: "CustomerID", aggregate: "count" },
                                        { field: "ShipName", aggregate: "count" },
                                        { field: "ShipCity", aggregate: "count" }
                                     ]
                            },

                            aggregate: [{ field: "OrderID", aggregate: "count" },
                                         { field: "CustomerID", aggregate: "count" },
                                         { field: "ShipName", aggregate: "count" },
                            ]
                        },
                        height: 280,
                        scrollable: {
                            virtual: false
                        },
                        sortable: true,
                        groupable: true,
                        columns: [
                           { field: "OrderID", aggregates: "count", groupHeaderTemplate: "OrderID: #= value # (Count: #= count#)" },
                            { field: "CustomerID", aggregates: "count", groupHeaderTemplate: "CustomerID: #= value # (Count: #= count#)", footerTemplate: "Total Count: #=count#" },
                            { field: "ShipName", title: "Ship Name", aggregates: "count", groupHeaderTemplate: "ShipName: #= value # (Count: #= count#)" },
                            { field: "ShipCity", title: "Ship City", aggregates: "count", groupHeaderTemplate: "ShipCity: #= value # (Count: #= count#)" }
                        ],
                        databound: function () {
                            $("#grid").find(".k-icon.k-collapse").trigger("click");
                        }
                    });
                   
                });

            </script>
        </div>

</body>
</html>

 

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 04 May 2012, 09:26 AM
Hello Kyle,

1) collapseGroup can be used to collapse a group item.
2) from the group desriptors of the DataSource you can determine on which fields grouping is applied.

For more details: http://jsfiddle.net/rusev/WNK4J/

All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Kyle
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or