EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: tenly on July 18, 2015, 06:42:19 PM



Title: PropertyGrid expandGroup/collaseGroup by GroupName?
Post by: tenly on July 18, 2015, 06:42:19 PM
I hope this is an easy question.

Is there a syntax that I can use to expand/collapse groups in a property grid by group name instead of group index?

Thanks in advance!


Title: Re: PropertyGrid expandGroup/collaseGroup by GroupName?
Post by: stworthy on July 19, 2015, 02:30:32 AM
Extend a 'groups' method to get all the groups.
Code:
$.extend($.fn.propertygrid.methods, {
groups: function(jq){
var opts = jq.propertygrid('options');
return opts.showGroup ? jq.datagrid('options').view.groups : [];
}
});

To expand/collapse a group, calculate the group index and then call 'expandGroup' or 'collpaseGroup' methods to achieve it.
Code:
var groupName = 'Status';
var pg = $('#pg');
var groups = pg.propertygrid('groups');
var index = $.inArray(groupName, $.map(groups, function(g){return g.value}));
pg.propertygrid('collapseGroup', index);