|
12 | 12 | * <li>.onCheckBoxChange - ( function(item) ) Called to notify when a checkbox selection changes, default is none |
13 | 13 | * <li>.itemsAvailable - (boolean) If 'false', displays the {@link patternfly.views.component:pfEmptyState Empty State} component. |
14 | 14 | * <li>.showCheckboxes - (boolean) Show checkboxes for row selection, default is true |
15 | | -* </ul> |
| 15 | + * </ul> |
16 | 16 | * @param {object} dtOptions Optional angular-datatables DTOptionsBuilder configuration object. See {@link http://l-lin.github.io/angular-datatables/archives/#/api angular-datatables: DTOptionsBuilder} |
17 | 17 | * @param {array} items Array of items to display in the table view. |
18 | | - * @param {array} columns Array of table column information to display in the table's header row |
| 18 | + * @param {array} columns Array of table column information to display in the table's header row and optionaly render the cells of a column. |
19 | 19 | * <ul style='list-style-type: none'> |
20 | 20 | * <li>.header - (string) Text label for a column header |
21 | 21 | * <li>.itemField - (string) Item field to associate with a particular column. |
| 22 | + * <li>.htmlTemplate - (string) (optional) id/name of an embedded ng/html template. Ex: htmlTemplate="name_template.html". The template will be used to render each cell of the column. |
| 23 | + * Use <code>handleColAction(key, value)</code> in the template to call the <code>colActionFn</code> callback function you specify. 'key' is the item attribute name; which should equal the itemFld of a column. |
| 24 | + * 'value' is the item[key] value. |
| 25 | + * <pre> |
| 26 | + * <script type="text/ng-template" id="name_template.html"> |
| 27 | + * <a href="" ng-click="$ctrl.handleColAction(key, value)">{{value}}</a> |
| 28 | + * </script> |
| 29 | + * </pre> |
| 30 | + * <li>.colActionFn - (function) (optional) Callback function used for the column. 'value' is passed as a paramenter to the |
| 31 | + * callback function. |
22 | 32 | * </ul> |
23 | 33 | * @param {array} actionButtons List of action buttons in each row |
24 | 34 | * <ul style='list-style-type: none'> |
|
36 | 46 | * @example |
37 | 47 | <example module="patternfly.tableview.demo"> |
38 | 48 | <file name="index.html"> |
| 49 | + <style> |
| 50 | + .truncate-text-container { |
| 51 | + position: relative; |
| 52 | + max-width: 100%; |
| 53 | + padding: 0 !important; |
| 54 | + display: -webkit-flex; |
| 55 | + display: -moz-flex; |
| 56 | + display: flex; |
| 57 | + vertical-align: text-bottom !important; |
| 58 | + } |
| 59 | + .truncate-text-ellipsis { |
| 60 | + position: absolute; |
| 61 | + white-space: nowrap; |
| 62 | + overflow-y: visible; |
| 63 | + overflow-x: hidden; |
| 64 | + text-overflow: ellipsis; |
| 65 | + -ms-text-overflow: ellipsis; |
| 66 | + -o-text-overflow: ellipsis; |
| 67 | + max-width: 100%; |
| 68 | + min-width: 0; |
| 69 | + top: 0; |
| 70 | + left: 0; |
| 71 | + } |
| 72 | + .truncate-text-container:after, |
| 73 | + .truncate-text-ellipsis:after { |
| 74 | + content: '-'; |
| 75 | + display: inline-block; |
| 76 | + visibility: hidden; |
| 77 | + width: 0; |
| 78 | + } |
| 79 | + </style> |
39 | 80 | <div ng-controller="ViewCtrl" class="row example-container"> |
40 | 81 | <div class="col-md-12"> |
41 | 82 | <pf-toolbar id="exampleToolbar" config="toolbarConfig"></pf-toolbar> |
|
76 | 117 | <div class="col-md-12"> |
77 | 118 | <textarea rows="6" class="col-md-12">{{actionsText}}</textarea> |
78 | 119 | </div> |
| 120 | + <script type="text/ng-template" id="status_template.html"> |
| 121 | + <span ng-if="value === 'error'" class="pficon pficon-error-circle-o"></span> |
| 122 | + <span ng-if="value === 'warning'" class="pficon pficon-warning-triangle-o"></span> |
| 123 | + <span ng-if="value === 'ok'" class="pficon pficon-ok"></span> |
| 124 | + {{value}} |
| 125 | + </script> |
| 126 | + <script type="text/ng-template" id="name_template.html"> |
| 127 | + <a href="" ng-click="$ctrl.handleColAction(key, value)">{{value}}</a> |
| 128 | + </script> |
| 129 | + <script type="text/ng-template" id="address_template.html"> |
| 130 | + <span class="truncate-text-container"> |
| 131 | + <span class="truncate-text-ellipsis" title="{{value}}"> |
| 132 | + {{value}} |
| 133 | + </span> |
| 134 | + </span> |
| 135 | + </script> |
79 | 136 | </div> |
80 | 137 | </file> |
81 | 138 |
|
|
89 | 146 | $scope.actionsText = ""; |
90 | 147 |
|
91 | 148 | $scope.columns = [ |
92 | | - { header: "Name", itemField: "name" }, |
| 149 | + { header: "Status", itemField: "status", htmlTemplate: "status_template.html" }, |
| 150 | + { header: "Name", itemField: "name", htmlTemplate: "name_template.html", colActionFn: onNameClick }, |
93 | 151 | { header: "Age", itemField: "age"}, |
94 | | - { header: "Address", itemField: "address" }, |
| 152 | + { header: "Address", itemField: "address", htmlTemplate: "address_template.html" }, |
95 | 153 | { header: "BirthMonth", itemField: "birthMonth"} |
96 | 154 | ]; |
97 | 155 |
|
|
120 | 178 |
|
121 | 179 | $scope.allItems = [ |
122 | 180 | { |
| 181 | + status: "error", |
123 | 182 | name: "Fred Flintstone", |
124 | 183 | age: 57, |
125 | 184 | address: "20 Dinosaur Way, Bedrock, Washingstone", |
126 | 185 | birthMonth: 'February' |
127 | 186 | }, |
128 | 187 | { |
| 188 | + status: "ok", |
129 | 189 | name: "John Smith", |
130 | 190 | age: 23, |
131 | 191 | address: "415 East Main Street, Norfolk, Virginia", |
132 | 192 | birthMonth: 'October' |
133 | 193 | }, |
134 | 194 | { |
| 195 | + status: "warning", |
135 | 196 | name: "Frank Livingston", |
136 | 197 | age: 71, |
137 | 198 | address: "234 Elm Street, Pittsburgh, Pennsylvania", |
138 | 199 | birthMonth: 'March' |
139 | 200 | }, |
140 | 201 | { |
| 202 | + status: "ok", |
141 | 203 | name: "Judy Green", |
142 | 204 | age: 21, |
143 | 205 | address: "2 Apple Boulevard, Cincinatti, Ohio", |
144 | 206 | birthMonth: 'December' |
145 | 207 | }, |
146 | 208 | { |
| 209 | + status: "ok", |
147 | 210 | name: "Pat Thomas", |
148 | 211 | age: 19, |
149 | 212 | address: "50 Second Street, New York, New York", |
150 | 213 | birthMonth: 'February' |
151 | 214 | }, |
152 | 215 | { |
| 216 | + status: "error", |
153 | 217 | name: "Linda McGovern", |
154 | 218 | age: 32, |
155 | 219 | address: "22 Oak Stree, Denver, Colorado", |
156 | 220 | birthMonth: 'March' |
157 | 221 | }, |
158 | 222 | { |
| 223 | + status: "warning", |
159 | 224 | name: "Jim Brown", |
160 | 225 | age: 55, |
161 | 226 | address: "72 Bourbon Way. Nashville. Tennessee", |
162 | 227 | birthMonth: 'March' |
163 | 228 | }, |
164 | 229 | { |
| 230 | + status: "ok", |
165 | 231 | name: "Holly Nichols", |
166 | 232 | age: 34, |
167 | 233 | address: "21 Jump Street, Hollywood, California", |
168 | 234 | birthMonth: 'March' |
169 | 235 | }, |
170 | 236 | { |
| 237 | + status: "ok", |
171 | 238 | name: "Wilma Flintstone", |
172 | 239 | age: 47, |
173 | 240 | address: "20 Dinosaur Way, Bedrock, Washingstone", |
174 | 241 | birthMonth: 'February' |
175 | 242 | }, |
176 | 243 | { |
| 244 | + status: "warning", |
177 | 245 | name: "Jane Smith", |
178 | 246 | age: 22, |
179 | 247 | address: "415 East Main Street, Norfolk, Virginia", |
180 | 248 | birthMonth: 'April' |
181 | 249 | }, |
182 | 250 | { |
| 251 | + status: "error", |
183 | 252 | name: "Liz Livingston", |
184 | 253 | age: 65, |
185 | 254 | address: "234 Elm Street, Pittsburgh, Pennsylvania", |
186 | 255 | birthMonth: 'November' |
187 | 256 | }, |
188 | 257 | { |
| 258 | + status: "ok", |
189 | 259 | name: "Jim Green", |
190 | 260 | age: 23, |
191 | 261 | address: "2 Apple Boulevard, Cincinatti, Ohio", |
192 | 262 | birthMonth: 'January' |
193 | 263 | }, |
194 | 264 | { |
| 265 | + status: "ok", |
195 | 266 | name: "Chris Thomas", |
196 | 267 | age: 21, |
197 | 268 | address: "50 Second Street, New York, New York", |
198 | 269 | birthMonth: 'October' |
199 | 270 | }, |
200 | 271 | { |
| 272 | + status: "error", |
201 | 273 | name: "Larry McGovern", |
202 | 274 | age: 34, |
203 | 275 | address: "22 Oak Stree, Denver, Colorado", |
204 | 276 | birthMonth: 'September' |
205 | 277 | }, |
206 | 278 | { |
| 279 | + status: "warning", |
207 | 280 | name: "July Brown", |
208 | 281 | age: 51, |
209 | 282 | address: "72 Bourbon Way. Nashville. Tennessee", |
210 | 283 | birthMonth: 'May' |
211 | 284 | }, |
212 | 285 | { |
| 286 | + status: "error", |
213 | 287 | name: "Henry Nichols", |
214 | 288 | age: 36, |
215 | 289 | address: "21 Jump Street, Hollywood, California", |
|
283 | 357 | } |
284 | 358 | } |
285 | 359 |
|
| 360 | + function onNameClick (name) { |
| 361 | + $scope.actionsText = "You clicked on " + name + "\n" + $scope.actionsText; |
| 362 | + } |
| 363 | +
|
286 | 364 | $scope.filterConfig = { |
287 | 365 | fields: [ |
288 | 366 | { |
|
0 commit comments