EasyUI Forum
September 14, 2025, 10:48:25 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Change behavior of propertygrid groups to be like an accordion  (Read 6597 times)
Max Lamda
Newbie
*
Posts: 48


View Profile
« on: November 04, 2015, 09:35:15 AM »

I just did a little change, that the datagrid-groups can only be opened exclusively:

onLoadSuccess: function() {

   var groupcount = 5;
   // Just use the correct number here ...
   // in Version 1.4.4 you can get the count via 'groups' method

   $(this).propertygrid('collapseGroup');
   $(this).propertygrid('expandGroup',0);

   var dg=this;
   $(this).parent().find('.datagrid-row-expander').on('click', function() {
      group=$(this).parents('.datagrid-group').attr('group-index');
      for(var i=0;i<groupcount;i++) {
         if(i!=group) {
            $(dg).propertygrid('collapseGroup', i);
         }
      }
   });
}
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: November 04, 2015, 05:08:20 PM »

Another better way to achieve this functionality is to override the 'expandGroup' method. Please try this:
Code:
(function($){
var expandGroup = $.fn.datagrid.methods.expandGroup;
$.fn.datagrid.methods.expandGroup = function(jq, groupIndex){
return jq.each(function(){
var pg = $(this);
var groups  = pg.datagrid('groups');
for(var i=0; i<groups.length; i++){
if (i != groupIndex){
pg.datagrid('collapseGroup', i);
} else {
expandGroup($(this), i);
}
}
})
}
})(jQuery);
Logged
Max Lamda
Newbie
*
Posts: 48


View Profile
« Reply #2 on: November 05, 2015, 04:34:30 AM »

Yes, thanks, but this would change the behavior for all propertygrids in my application.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!