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

Expand Specific Groups on External Button click

3 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 23 May 2013, 06:23 PM
I am looking at your sample on how to Expand/Collapse grouped grid client-side on external control click and I get this to work fine to expand or contract all the groups.

function toggleGroup(e) {
                var tableView=$find('<%=RadGrid1.ClientID %>').get_masterTableView();

                var rows=tableView.get_element().rows;
                for(var i=0,len=tableView.get_element().rows.length;i<len;i++) {
                    var button=tableView._getGroupExpandButton(rows[i]);
                    if(button) {
                        var groupLevel=button.id.split("__")[2];

                        if(groupLevel==0) {
                            tableView._toggleGroupsExpand(button,e);
                        }
                    }
                }
            }

However what I need is to only expand certain groups that the button pertains to. Is there a way to iterate through the group headers and only expand certain ones. I am stumped at finding a way to access the group header text in Javascript.

I am setting the group header text in the ItemDataBound like this
    If TypeOf e.Item Is GridGroupHeaderItem Then
            Dim GroupHeader As GridGroupHeaderItem = DirectCast(e.Item, GridGroupHeaderItem)
            Dim item As GridGroupHeaderItem = DirectCast(e.Item, GridGroupHeaderItem)
            Dim groupDataRow As DataRowView = DirectCast(e.Item.DataItem, DataRowView)
            item.DataCell.Text = groupDataRow.Row.ItemArray(0).ToString()
     End If

3 Answers, 1 is accepted

Sort by
0
Accepted
Kostadin
Telerik team
answered on 28 May 2013, 08:35 AM
Hi Steven,

A possible solution is to get the group headers text and expand only certain groups. For your convenience I prepared a small sample and attached it to this thread.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Steven
Top achievements
Rank 1
answered on 28 May 2013, 02:20 PM
This is working great if I use it on a grid with paging, but fails if I enable scrolling. Is there a way to do this with a scrolling grid?

0
Steven
Top achievements
Rank 1
answered on 28 May 2013, 02:45 PM
I found out how to do it. I just replaced the var text = rows[i].getElementsByTagName('p')[0].innerHTML; with var text = rows[i].getElementsByTagName('div')[2].innerHTML;

Thanks for the help!!
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Steven
Top achievements
Rank 1
Share this question
or