Michael JDI
Michael JDI

Reputation: 1251

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?

Upvotes: 3

Views: 6376

Answers (2)

Idan Gozlan
Idan Gozlan

Reputation: 3203

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)"

Upvotes: 5

Kathir
Kathir

Reputation: 6196

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.

Upvotes: 3

Related Questions