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

Hierarchy grid collapsed by default

7 Answers 670 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 28 Feb 2012, 10:44 PM
Is there any option to have the grid start off collapsed instead of having the first row expanded to see the nested grid?

7 Answers, 1 is accepted

Sort by
0
Justin
Top achievements
Rank 1
answered on 29 Feb 2012, 05:19 PM
Any help on this?

I've been trying to just collapse the row right away but it's not working. I'm pretty much just using straight example code at the moment. 'grid.tbody.find(">tr.k-master-row:first")' doesn't find anything. I would much rather just have a flag to set whether or not it should open up automatically or start collapsed.

		<script type="text/javascript">
			$(document).ready(function () {
				var grid = $("#grid").kendoGrid(
				{
					dataSource:
					{
						type: "odata",
						transport: {
							read: "http://demos.kendoui.com/service/Northwind.svc/Employees"
						},
						pageSize: 250,
						serverPaging: true,
						serverSorting: true
					},
					height: 450,
					sortable: true,
					pageable: true,
					detailInit: detailInit,
					dataBound: function () {
						this.expandRow(this.tbody.find("tr.k-master-row").first());
					},
					columns: [
								{
									field: "FirstName",
									title: "First Name"
								},
								{
									field: "LastName",
									title: "Last Name"
								},
								{
									field: "Country"
								},
								{
									field: "City"
								},
								{
									field: "Title"
								}
							]
				});
 
				var grid = $("#grid").data("kendoGrid");
				grid.collapseRow(grid.tbody.find(">tr.k-master-row:first"));
			});
 
			function detailInit(e) {
				$("<div/>").appendTo(e.detailCell).kendoGrid({
					dataSource: {
						type: "odata",
						transport: {
							read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
						},
						serverPaging: true,
						serverSorting: true,
						serverFiltering: true,
						pageSize: 6,
						filter: { field: "EmployeeID", operator: "eq", value: e.data.EmployeeID }
					},
					scrollable: false,
					sortable: true,
					pageable: true,
					columns: ["OrderID""ShipCountry""ShipAddress""ShipName"]
				});
			}
		</script>
0
Demi
Top achievements
Rank 1
answered on 22 Mar 2012, 06:50 PM
Would love to know this too!
0
David
Top achievements
Rank 1
answered on 23 Mar 2012, 04:32 PM
Remove the dataBound function.
0
Juan
Top achievements
Rank 1
answered on 26 Mar 2012, 07:18 PM
hello, how are the schemas of the data?  
Because I'm testing a hierarchy grid using data in XML and filtering, but it doesn't work fine.
Thanks you.
0
Avitot
Top achievements
Rank 1
answered on 24 Jul 2012, 07:05 AM
Hello Justin,

Kendo grid is all collapsed by default.
You just need to remove this line as David says:

        dataBound: function () {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
        },

Hope this helps,
Avi

0
Richard
Top achievements
Rank 1
answered on 09 Dec 2016, 03:36 PM
Is it also possibility to keep 1 row expanded at a time, which means if a row is already open, it will collapse.
0
Dimiter Topalov
Telerik team
answered on 14 Dec 2016, 12:40 PM
Hello Richard,

You can handle the Grid's detailExpand event, and close other expanded rows (if any) programmatically via the collapseRow() method:

http://dojo.telerik.com/awOdu

I hope this helps.

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.
Tags
Grid
Asked by
Justin
Top achievements
Rank 1
Answers by
Justin
Top achievements
Rank 1
Demi
Top achievements
Rank 1
David
Top achievements
Rank 1
Juan
Top achievements
Rank 1
Avitot
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Dimiter Topalov
Telerik team
Share this question
or