Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

Define ng-click on rows #33

Closed
greghaar opened this issue Jul 16, 2014 · 2 comments
Closed

Define ng-click on rows #33

greghaar opened this issue Jul 16, 2014 · 2 comments

Comments

@greghaar
Copy link

Have been looking for a decent grid for a while now and wasn't happy at all with ng-grid, ng-table, wijmo or kendo... this looks SUPER promising.

I'm trying to convert an ng-table directive that contained an ng-click="open(myItems.id)" directive on which would call the open method in the controller (and handle opening a new route with the details for that record). It's not entirely clear if that's possible or how I would do that in trNgGrid, both defining a custom click method in place of selections or referencing that row's id value.

Any ideas, or is this possible as an enhancement?

Thanks for the great work to date, it seems like you've made some serious progress in the last few months!

@rphilp
Copy link

rphilp commented Jul 16, 2014

I do something similar, but instead of routing to a new page, I just display the details below. I'll post what I use below. This is probably not the best way to do it, but it should work.

<table items="offices" tr-ng-grid="" selected-items="officeDetails" 
           selection-mode="SingleRow"></table>
$scope.$watch('officeDetails[0]', function (value) {
     $scope.offDetail = _.find($scope.offices, function (office) {
          return office.officeId === value.officeId
     })
});

@MoonStorm
Copy link
Owner

Yep, that is the way to go:

  1. Monitor the collection you attach to selected-items.
  2. Alternatively, if you don't need more data, you could directly couple the first item in the selection collection directly to a div having a ng-if or ng-show directive.

The grid uses dual data binding for most of its features which makes it convenient to attach extra logic, the Angular way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants