1

How can I get a row value, when click cell in ng-grid?

example:

Name   Number  Class

X      123      A

Y      234      B

Z      345      C

A      456      D

When click on 123 cell or A cell or X cell, how can i get value X.

Please any help me. thanks in Advance

2 Answers 2

0

You should write ng-click of cellTemplate ng-click="clicked(row)"

Controller

$scope.clicked = function(row){
   alert(row.getProperty("Name"));
};
Sign up to request clarification or add additional context in comments.

4 Comments

Hi @pankajparkar, when i click any cell, i want corresponding name value. how can i get the value
@stackoverflow you need to add ng-click in cellTemplate of colunn
Hi @pankajparkar, i have ng-clcik in cellTemplate only, but hiw can i get name values when click on number cell or class Cell, can please help me it
you ng-click of cell template should be ng-click="clicked(row, col)", did you tried the changes which i suggested
0

One option - add an ng-click function on each row that returns the value in the first column.

HTML

<tr ng-repeat="item in items" ng-click="getVal(item)">
  <td>{{item.name}}</td>
  <td>{{item.number}}</td>
  <td>{{item.class}}</td>
</tr>

Controller

$scope.getVal = function(item) {
    alert(item.name);
}

Here's a working demo.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.