Skip to content

Commit 589124f

Browse files
Add ability to set a class on list view rows, use customScope
Set a class specified by the row item on the row’s container (list-group-item). Adds a customScope parameter to allow the transcluded html to use variables or functions defined by the applications scope.
1 parent 723fc26 commit 589124f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/views/listview/list-view-directive.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
*
55
* @description
66
* Directive for rendering a list view.
7+
* Pass a customScope object containing any scope variables/functions you need to access from the transcluded source, access these
8+
* via 'customScope' in your transcluded hmtl.
79
* <br><br>
810
*
9-
* @param {array} items Array of items to display in the list view
11+
* @param {array} items Array of items to display in the list view. If an item in the array has a 'rowClass' field, the value of this field will be used as a class specified on the row (list-group-item).
1012
* @param {object} config Configuration settings for the list view:
1113
* <ul style='list-style-type: none'>
1214
* <li>.showSelectBox - (boolean) Show item selection boxes for each item, default is true
@@ -39,6 +41,7 @@
3941
* <li>.isSeparator - (Boolean) set to true if this is a placeholder for a separator rather than an action
4042
* </ul>
4143
* @param {function (action, item))} updateMenuActionForItemFn function(action, item) Used to update a menu action based on the current item
44+
* @param {object} customScope Object containing any variables/functions used by the transcluded html, access via customScope.<xxx>
4245
* @example
4346
<example module="patternfly.views" deps="patternfly.utils">
4447
<file name="index.html">
@@ -301,7 +304,8 @@ angular.module('patternfly.views').directive('pfListView', function ($timeout, $
301304
menuActions: '=?',
302305
updateMenuActionForItemFn: '=?',
303306
actions: '=?',
304-
updateActionForItemFn: '=?'
307+
updateActionForItemFn: '=?',
308+
customScope: '=?'
305309
},
306310
transclude: true,
307311
templateUrl: 'views/listview/list-view.html',

src/views/listview/list-view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="list-view-pf">
2-
<div class="list-group-item"
2+
<div class="list-group-item {{item.rowClass}}"
33
ng-repeat="item in items track by $index"
44
ng-class="{'pf-selectable': selectItems, 'active': isSelected(item), 'disabled': checkDisabled(item)}">
55
<div class="list-view-pf-checkbox" ng-if="config.showSelectBox" >

0 commit comments

Comments
 (0)