1

Starting out on AngularJS and KendoUI Grid. I'd like to get the row value for a defined grid.

I've defined a button template in my Kendo UI Grid as follows:

$scope.gridOptions = {
  dataSource: {
                type: "json",
                data: $scope.teams,
                pageSize: 5
            },
  sortable: true,
  selectable: row,
  columns: [
    {field: "TeamID", title: "Team ID"},
    {field: "TeamName", title: "Name" },
    {field: "TeamDistrict", title: "District"},
    {
     template: "<button class=\"k-button\" ng-click=\"manageTeam(#=TeamID#)\">Manage</button>"
    }
  ]
};

I also defined a function as follows:

$scope.manageTeam = function(tid){
  console.log(tid);
};

I am getting the value for the passed Team ID, but I wanted to grab the whole row value into an object so that I can get it like:

$scope.manageTeam = function(rowValue){
  console.log(rowValue.TeamID);
  console.log(rowValue.TeamName);
  console.log(rowValue.TeamDistrict);
};

Appreciate any insight on how to achieve this. Thanks.

3
  • Try using #=this# instead of #=TeamID# in the manageTeam() call of your button template. I'm not sure what you'll get, but it's worth a shot. Commented Oct 16, 2014 at 15:50
  • Tried. Got error: Error: [$parse:syntax] Syntax Error: Token 'Window' is unexpected, expecting []] at column Commented Oct 16, 2014 at 16:17
  • Thanks for your comment. Was able to find an answer. Commented Oct 16, 2014 at 17:30

1 Answer 1

5

Thanks to @CSharper, I was able to map out the answer.

The key is to change the template attribute in the columns declaration to:

template: "<button class=\"k-button\" ng-click=\"manageTeam(this.dataItem)\">Manage</button>"

Hope someone finds this stuff useful.

Sign up to request clarification or add additional context in comments.

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.