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

[Solved] How can groups be set to collapsed by default when using Groupable?

6 Answers 262 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Stephen
Top achievements
Rank 1
Stephen asked on 21 May 2010, 03:10 PM
Hello,
We are using the inbuilt GroupBy but cannot see an option to make it default to "collapsed" by default. By default groups are rendered pre-expanded - is there a way of changing this? If so, how?

Current:
// Grid definition etc 
    .Groupable(groupable => groupable.Enabled(true).Groups(groups =>  
        groups.Add(g => g.GroupByField) 
   )) 

Ideal:
// Grid definition etc  
    .Groupable(groupable => groupable 
        .Enabled(true
        .Expanded(false
        .Groups(groups =>   
            groups.Add(g => g.GroupByField)  
   ))  


Thanks
Stephen

6 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 24 May 2010, 09:23 AM
Hi,

Try with Ajax binding only. I don't believe that you can set grid to render groups collapsed with server binding.

Regards,
Peter
0
Stephen
Top achievements
Rank 1
answered on 24 May 2010, 10:25 AM
Hi Peter
Thanks for the response. I've checked out AJAX binding and cannot find how to do it that way either... could you be more specific?

Thanks
Stephen
0
Peter
Top achievements
Rank 1
answered on 24 May 2010, 12:17 PM
Hi,

Check this online help article and the online demo. You can also review the examples locally to find out how Ajax binding is realized.

Regards,
Peter
0
Stephen
Top achievements
Rank 1
answered on 24 May 2010, 12:33 PM
Hi Peter
Sorry, I should have been more specific. I have no difficulties setting up the AJAX binding and associated controller actions (and have done so in our test project).

I do, however, fail to see any difference with the available grouping options when using AJAX binding instead of Server Binding, or how using AJAX binding helps overcome the issue mentioned in my original post. Neither of the help documents you specified shed any light on the subject either, or even mention grouping - and the available documentation on grouping does not contain any clues as to how the groups could be initially rendered as collapsed (I did check before posting).

To rephrase, could you be more specific about how using AJAX binding could be utilized to render groups as "collapsed" instead of "expanded" when the grid is initially loaded?

Thanks
Stephen
0
Georgi Krustev
Telerik team
answered on 24 May 2010, 05:12 PM
Hello Stephen,

Currently grid does not support rendering of collapsed groups. Nevertheless we will consider the possibility to implement this feature in one of our future releases. I will forward this issue to our developers for further investigation and consideration.

Regards,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Nikolai
Top achievements
Rank 1
answered on 07 Apr 2011, 09:51 PM

I succeded by firing up the OnLoad Client event:

.ClientEvents(events => 

{

 

 

    events.OnLoad("collapseMVCGroupedGrids"

);})

and following JavaScript:

 

 

 

function

 

 

collapseMVCGroupedGrids(e) { 

 

 

 

 

var grid = $('#' + e.target.id); 

 

 

$.each(
        
grid.find('td.t-group-cell').parent('tr'), 
        
function(index, value) { 
                                    
$(value).attr('style', 'display: none;');  

 

 

                               }
      );

 

 

 

$.each(
        grid

 

 

.find('.t-icon'), 
        
function(index, value) {
                                    if ($(value).hasClass('t-collapse' )) { 
                                        
$(value).removeClass('t-collapse').addClass('t-expand'); 

 

 

                                }

 

        });
}

Enjoy!

 

 

 

 

Tags
Grid
Asked by
Stephen
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Stephen
Top achievements
Rank 1
Georgi Krustev
Telerik team
Nikolai
Top achievements
Rank 1
Share this question
or