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

accordion behavior in hierarchical grid

2 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Muhammad
Top achievements
Rank 1
Muhammad asked on 23 Nov 2017, 02:11 PM
I have a hierarchical grid in which i want to have only one row expanded at a time.  

2 Answers, 1 is accepted

Sort by
0
Accepted
Preslav
Telerik team
answered on 24 Nov 2017, 07:37 AM
Hi Muhammad,

Achieving the desired behavior will require the usage of the detailExpand event and the collapseRow method.
For example, in the detailExpand event handler, get all the master rows without the one that invoked the event(e.masterRow). Then, use the collapseRow for every master row. The code could look like:

detailExpand: function(e) {
  var grid = e.sender;
  var rows = grid.element.find(".k-master-row").not(e.masterRow);
   
  rows.each(function(e){
    grid.collapseRow(this);
  });
},

For a runnable example, check my testing Dojo:

Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Muhammad
Top achievements
Rank 1
answered on 24 Nov 2017, 09:20 PM
Thanks
Tags
Grid
Asked by
Muhammad
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Muhammad
Top achievements
Rank 1
Share this question
or