Unable to select the grid item using SmartTable in Angular JS
Asked Answered
S

2

8

I have implemented grid using SmartTable in Angular JS. According to Smart Table docs, for selecting the grid item, we need to add st-select-row="row". I added this one too. But i am unable to select the grid.

Implemented app can be seen in plunk (url below). Can anybody please help me to use the grid row as selectable. Also, I want to call a function when clicking on row.

Plunkr here

Susannsusanna answered 27/10, 2014 at 9:49 Comment(0)
Q
19

Your plunker actually works

when selecting a row smart-table add the property isSelected=true to the associated model and a class name st-selected to the tr element

just add a css rule and you'll be able to see it

.st-selected{
  border-left:4px solid black;
}
Quiteris answered 28/10, 2014 at 5:21 Comment(2)
While clicking on row i want to call one function. How i can do.Susannsusanna
Use ng-click="functionToCall()"Muskogean
I
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>
	<th st-sort="firstName">first name</th>
	<th st-sort="lastName">last name</th>
	<th st-sort="birthDate">birth date</th>
	<th st-sort="balance">balance</th>
	<th>email</th>
</tr>
</thead>
<tbody>
<tr st-select-row="row" st-select-mode="multiple" ng-repeat="row in rowCollection">
	<td>{{row.firstName | uppercase}}</td>
	<td>{{row.lastName}}</td>
	<td>{{row.birthDate | date}}</td>
	<td>{{row.balance | currency}}</td>
	<td><a ng-href="mailto:{{row.email}}">email</a></td>
</tr>
</tbody>
</table>
Ivanivana answered 1/2, 2016 at 12:54 Comment(1)
İf you want to single select ; You can write st-select-mode="single"Shannashannah

© 2022 - 2024 — McMap. All rights reserved.