2014-10-16 59 views
1

從AngularJS和KendoUI Grid開始。我想獲取定義網格的行值。在AngularJS中獲取Kendo UI Grid的行值

我如下定義在我的劍道UI欄按鈕模板:

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

我得到了通過團隊的價值:

$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>" 
    } 
    ] 
}; 

我也如下定義的函數ID,但是我想把整行的值放到一個對象中,這樣我就可以得到它:

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

Appre有關如何實現這一點的任何見解。謝謝。

+0

嘗試在按鈕模板的manageTeam()調用中使用'#= this#'而不是'#= TeamID#'。我不確定你會得到什麼,但它值得一試。 – Brett 2014-10-16 15:50:30

+0

試過了。有錯誤:錯誤:[$ parse:syntax]語法錯誤:令牌'窗口'出乎意料,期望[]]在列 – Batuta 2014-10-16 16:17:13

+0

感謝您的評論。能夠找到答案。 – Batuta 2014-10-16 17:30:50

回答

5

感謝@CSharper,我能夠找出答案。

的關鍵是在列聲明中更改模板屬性:

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

希望有人認爲這個東西是有用的。