Sudarshan
Sudarshan

Reputation: 8664

AngularJS ng-grid with custom button

I am using angular button in a ng-grid. I need to know how can i identity which button was clicked from within the grid.

I guess part of the complexity is that the button is clicked before the row is selected (Just my analysis,probably wont help with the solution :)

A snap shot of how the grid looks

ng-grid

A plunker illustrating the problem here

Upvotes: 25

Views: 18905

Answers (2)

nichols
nichols

Reputation: 86

@Shai Aharoni You can prevent the row from being selected by passing $event as the first argument to the click handler:

.. ng-click="edit($event, row)">Edit</button>

and then calling stopPropagation() on the event from inside the handler.

$scope.edit = function(event, row) { event.stopPropagation(); }

Upvotes: 5

Sudarshan
Sudarshan

Reputation: 8664

I have been able to find out how to resolve my question,basically pass in "row" as an argument on your function for ng-click. ng-click="save(row)"

Before

.. ng-click="edit(selectedItem)" >Edit</button> '

After

.. ng-click="edit(row)" >Edit</button> '

I have updated the plunker here to reflect the same

row.entity will give me the entity bound to this row of the grid

Upvotes: 26

Related Questions