2014-10-27 41 views
8

我已經在Angular JS中使用SmartTable實施了網格。根據Smart Table文檔,爲了選擇網格項目,我們需要添加st-select-row="row"。我也加了這個。但我無法選擇網格。無法使用Angular JS中的SmartTable選擇網格項目

實現的應用程序可以在plunk中看到(網址如下)。任何人都可以幫助我使用網格行可選。此外,我想調用功能點擊

Plunkr here

回答

19

選擇行智能表的屬性isSelected=true添加到相關模型和類名st-selected於TR元件的時候你plunker實際工作

只需添加一個CSS規則你就可以看到它

.st-selected{ 
    border-left:4px solid black; 
} 
+1

雖然點擊行我想調用一個函數。我該怎麼做。 – 2014-10-29 08:42:09

+1

使用ng-click =「functionToCall()」 – 2015-02-17 17:35:59

+0

這節省了我的一天!許多感謝@laurent – codeMan 2016-05-30 11:19:45

1

app.controller('selectionCtrl', ['$scope', '$filter', function (scope, filter) { 
 
    scope.rowCollection = [ 
 
     {firstName: 'Laurent', lastName: 'Renard', birthDate: new Date('1987-05-21'), balance: 102, email: '[email protected]'}, 
 
     {firstName: 'Blandine', lastName: 'Faivre', birthDate: new Date('1987-04-25'), balance: -2323.22, email: '[email protected]'}, 
 
     {firstName: 'Francoise', lastName: 'Frere', birthDate: new Date('1955-08-27'), balance: 42343, email: '[email protected]'} 
 
    ]; 
 
}]);
.st-selected{ 
 
    color:cornflowerblue ; 
 
}
<table st-table="rowCollection" class="table"> 
 
<thead> 
 
<tr> 
 
\t <th st-sort="firstName">first name</th> 
 
\t <th st-sort="lastName">last name</th> 
 
\t <th st-sort="birthDate">birth date</th> 
 
\t <th st-sort="balance">balance</th> 
 
\t <th>email</th> 
 
</tr> 
 
</thead> 
 
<tbody> 
 
<tr st-select-row="row" st-select-mode="multiple" ng-repeat="row in rowCollection"> 
 
\t <td>{{row.firstName | uppercase}}</td> 
 
\t <td>{{row.lastName}}</td> 
 
\t <td>{{row.birthDate | date}}</td> 
 
\t <td>{{row.balance | currency}}</td> 
 
\t <td><a ng-href="mailto:{{row.email}}">email</a></td> 
 
</tr> 
 
</tbody> 
 
</table>

+0

如果你想單選;你可以寫st-select-mode =「single」 – 2016-02-01 13:01:11