【问题标题】:Unable to select the grid item using SmartTable in Angular JS无法在 Angular JS 中使用 SmartTable 选择网格项
【发布时间】:2014-10-27 09:49:13
【问题描述】:

我在 Angular JS 中使用 SmartTable 实现了网格。根据 Smart Table docs,为了选择网格项,我们需要添加 st-select-row="row"。我也加了这个。但我无法选择网格。

可以在 plunk 中看到已实现的应用程序(网址如下)。谁能帮我将网格行用作可选。另外,我想在单击时调用函数

Plunkr here

【问题讨论】:

    标签: angularjs smart-table


    【解决方案1】:

    你的 plunker 确实有效

    选择行智能表时,将属性 isSelected=true 添加到关联模型,将类名 st-selected 添加到 tr 元素

    只需添加一个css规则,你就可以看到它

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

    【讨论】:

    • 点击行时我想调用一个函数。我该怎么办。
    • 使用 ng-click="functionToCall()"
    【解决方案2】:

    app.controller('selectionCtrl', ['$scope', '$filter', function (scope, filter) {
        scope.rowCollection = [
            {firstName: 'Laurent', lastName: 'Renard', birthDate: new Date('1987-05-21'), balance: 102, email: 'whatever@gmail.com'},
            {firstName: 'Blandine', lastName: 'Faivre', birthDate: new Date('1987-04-25'), balance: -2323.22, email: 'oufblandou@gmail.com'},
            {firstName: 'Francoise', lastName: 'Frere', birthDate: new Date('1955-08-27'), balance: 42343, email: 'raymondef@gmail.com'}
        ];
    }]);
    .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>

    【讨论】:

    • İ如果你想单选;你可以写 st-select-mode="single"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-18
    • 2020-09-04
    相关资源
    最近更新 更多