Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI-GRID Expandable Grid. Programatically expand one row

I want to hide the + icon in the far left column and add another icon.

When the user clicks the new Icon I want to programatically expand that specific row.

I see there is gridApi.expandable.expandAllRows();

Is there a way to expand just one row?

like image 773
Michael JDI Avatar asked May 29 '26 13:05

Michael JDI


2 Answers

You can use toggleRowExpansion function, add this attribute to the desired element which will be trigger this toggle:

ng-click="grid.api.expandable.toggleRowExpansion(row.entity)"

like image 185
Idan Gozlan Avatar answered Jun 04 '26 12:06

Idan Gozlan


If all you want is to change the default plus icon to a different icon, you can simply override the template for the expandableRowHeader.

$templateCache.put('ui-grid/expandableRowHeader',
    "<div class=\"ui-grid-row-header-cell ui-grid-expandable-buttons-cell\"><div class=\"ui-grid-cell-contents\"><i ng-class=\"{ 'ui-grid-icon-plus-squared' : !row.isExpanded, 'ui-grid-icon-minus-squared' : row.isExpanded }\" ng-click=\"grid.api.expandable.toggleRowExpansion(row.entity)\"></i></div></div>"
  );

You can change the ng-class=\"{ 'ui-grid-icon-plus-squared' : !row.isExpanded, 'ui-grid-icon-minus-squared' : row.isExpanded }\" and change them to a different icon of your choice.

like image 28
Kathir Avatar answered Jun 04 '26 13:06

Kathir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!