AngularJS ng-grid with custom button

18,873

Solution 1

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

Solution 2

@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(); }
Share:
18,873

Related videos on Youtube

Sudarshan
Author by

Sudarshan

Sudarshan is a software professional with around 8 years experience in designing and developing enterprise Java applications. He has worked across a broad spectrum of technologies including but not limited to Mule ESB ( and it's surrounding technology stack), Spring, Hibernate, ZKOSS, Struts, Groovy, MongoDB and MySQL. He has exposure to the complete SDLC - architecture/design, building proof of concepts, development, unit and integration testing and early life production support. He is a certified MuleSoft Developer with a strong focus on analysis, design, development and implementation of EAI projects and sound knowledge of Message Integration Patterns. He has worked extensively on REST API design, development and management based on RAML specifications. His special interests include solution design, systems integration, Domain Driven Design, Command Query Responsibility Segregation (CQRS), Test Driven Development (TDD) and continuous integration. He is passionate about clean code and software craftsmanship - this passion delivers value to clients because clean code typically has fewer bugs than messy code and is less dearer to maintain. He is a strong advocate of a quality-oriented development environment (with CI, Sonar, automatic deployment, etc.)

Updated on September 14, 2022

Comments

  • Sudarshan
    Sudarshan over 1 year

    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